Open pylang opened 6 years ago
Maybe of interest: I wrote a small package ipytest
, which allows to run tests defined inside notebooks.
@chmp You should be commended on a brilliant attempt at tackling this. This is the best option I see so far.
In your README, you identify a few issues that are not obvious to most people and require attention, particularly with clearing the notebook globals when running tests. In the future, I hope there will be more dialog between the jupyter and pytest teams on making a idiomatic solution. Preferably, all the required boilerplate would be:
import pytest
%pytest
I am a bit hesitant to pepper additional magic throughout my notebooks to run tests. It is the only reason I still use nose
. ))
@pylang Thanks a lot for the feedback. I understand your comment to have two parts:
ipytest
version (0.4.0b1
) does not longer require magics to rewrite asserts.Since I do not want to highjack the notebook
issue tracker for ipytest
issues, I collected my comments here. Feel free to comment and re-open the issue in case the changes do not work for you.
There has been some discussion at pytest-dev on adding some way to run pytest in notebooks.
One proposal has been to invoke a magic similar to
%matplotlib
at the start of the notebook. This would a override the normal assertion output for any cell with pytest's detailed output (see example here).Can we have a
%pytest
implemented as one of the builtin magics in jupyter notebooks?