You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which simply contains a single cell with this code:
defanswer():
return42
calling that function via testbook repeatedly (500+ times) will fail. Doing this:
fromtestbookimporttestbook@testbook('answer.ipynb', execute=True)deftest_func(tb):
answer=tb.get("answer")
for_inrange(500):
assertanswer() ==42if__name__=="__main__":
test_func() # runnable with pure Python instead of pytest
results in:
Traceback (most recent call last):
File "/home/florian/tmp/testbook/.venv/lib/python3.10/site-packages/nbformat/_struct.py", line 128, in __getattr__
result =self[key]
KeyError: 'data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/florian/tmp/testbook/test_answer.py", line 10, in <module>
test_func()
File "/home/florian/tmp/testbook/testbook/testbook.py", line 63, in wrapperreturn func(self.client, *args, **kwargs)
File "/home/florian/tmp/testbook/test_answer.py", line 7, in test_funcassert answer() ==42
File "/home/florian/tmp/testbook/testbook/reference.py", line 85, in __call__returnself.tb.value(code)
File "/home/florian/tmp/testbook/testbook/client.py", line 302, in valuereturn outputs[0].data['application/json']['value']
File "/home/florian/tmp/testbook/.venv/lib/python3.10/site-packages/nbformat/_struct.py", line 130, in __getattr__raiseAttributeError(key)
AttributeError: data
Maybe instead of using outputs[0] there, testbook should find the first execute_result output or so? Though I'm also wondering if there's a way for testbook to prevent that warning altogether.
The text was updated successfully, but these errors were encountered:
With a trivial
answer.ipynb
like this:which simply contains a single cell with this code:
calling that function via testbook repeatedly (500+ times) will fail. Doing this:
results in:
here:
testbook/testbook/client.py
Line 302 in e2ae899
Adding a
print(outputs)
there reveals why:coming from IPython's displayhook.
Maybe instead of using
outputs[0]
there, testbook should find the firstexecute_result
output or so? Though I'm also wondering if there's a way for testbook to prevent that warning altogether.The text was updated successfully, but these errors were encountered: