Code Monkey home page Code Monkey logo

Comments (6)

sidujjain avatar sidujjain commented on June 20, 2024 2

Thanks for the quick fix @rohitsanj ! Works like a charm!

from testbook.

MSeal avatar MSeal commented on June 20, 2024

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.

rohitsanj avatar rohitsanj commented on June 20, 2024

@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.

sidujjain avatar sidujjain commented on June 20, 2024

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.

MSeal avatar MSeal commented on June 20, 2024

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.

rohitsanj avatar rohitsanj commented on June 20, 2024

@sidujjain Please upgrade to testbook 0.2.6 and the issue should be fixed!

pip install -U testbook

from testbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.