Comments (6)
Thanks for the quick fix @rohitsanj ! Works like a charm!
from testbook.
So I have a fix for the type error occurring when reporting the value of foo(2)
.
However the root problem is that testbook is using the _
variable to fetch the execution value of the last cell. In ipython this has special meaning:
In [1]: 1 + 1
Out[1]: 2
In [2]: _
Out[2]: 2
However when you do an underscore assignment like _ = 20
you permanently assign that variable to 20 causing all 'last-value' checks to say they got a value of 20.
In [1]: _ = 20
In [2]: 1 + 1
Out[2]: 2
In [3]: _
Out[3]: 20
Generally I would avoid doing _
assignments within a notebook, though I'll submit the patch here in a second to make it so the assertion at least reports the error accurately as 20 == 3
assertion failure.
from testbook.
@sidujjain Thanks for reporting. Will look into this now.
@MSeal thanks for the change, I'll see if I can add a fix to the same PR.
from testbook.
Thanks for the quick response, @MSeal ! Using _
is a common pattern in python for unpacking tuples or in loops.
I wonder if there is a way to capture the output in a different way or to reset _
before running the Testbook tests.
from testbook.
Yeah I know, though it's somewhat more of an ipython limitation: https://stackoverflow.com/questions/56734319/reset-underscore-variable-in-jupyter-notebook-powered-by-ipython-kernel. That link has some paths to fix the root issue. @rohitsanj we could see about forcing the result outcome each injection to see if we can auto-repair it?
from testbook.
@sidujjain Please upgrade to testbook 0.2.6 and the issue should be fixed!
pip install -U testbook
from testbook.
Related Issues (20)
- Getting an InterpreterNotFoundError on running the command tox -e py36 during setup HOT 1
- Document `nb` attribute and how it represents the nbformat object
- Entire notebook executed before the specific method HOT 3
- Testbook fails when using pytest test-classes HOT 2
- Support for objects as return_value when patching HOT 1
- Testbook giving timeout error because of nbclient HOT 1
- testbook loads wrong signature for function HOT 1
- Use pickle instead of JSON for serialization HOT 1
- support `async` function calls
- Asyncio errors and intermittent test failure
- Add support for SKIPPING cells' execution HOT 3
- Return value as None from testbook function HOT 4
- Mention in the contributing docs that an `ipykernel` with name `python3` must be present for tests to run locally
- Incompatibility between `execute=False` and `tb.patch()`
- testbook.ref cannot recognize complex variable
- `AttributeError: data` when repeatedly calling same function
- Because of project structure, relative paths in Notebook are no longer valid when testbook executes Notebook before tests HOT 1
- ModuleNotFoundError while using @testbook('....ipynb', execute=True) HOT 1
- Add type annotations
- Remove codecov dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testbook.