zonca/pytest-ipynb

ENH: Cell independence?

Closed this issue · 3 comments

I noticed that objects that I create in one cell survive to subsequent cells. This is usually not a problem with tests in functions, but I prefer to have the tests NOT in functions, so that I can live execute them without requiring a function call, for me this interactivity is a major feature of this plugin.
While I am constantly aware of objects being alive somewhere in my notebook, could the plugin maybe delete objects between cell executions when called by py.test? I think that could prevent hidden bugs in testing code.

zonca commented

there must be a bug somewhere, in runtest I restart the kernel, that should wipe all other stuff and just rerun the fixture and the cell:

    self.parent.runner.km.restart_kernel()
zonca commented

Can you show me an example of this?

If I do:

a = 3

in the first cell and:

print(a)

in the second cell.
I get a not defined.

Pity that I did not create an example. I cannot recreate at the moment, let's close it for now, thanks.