[TIP] pytest and ipynb
Hans Fangohr
fangohr.hans at gmail.com
Tue Jun 21 09:58:05 PDT 2016
Pete, and all,
> On 18 Jun 2016, at 08:29, Pete Forman <petef4+usenet at gmail.com> wrote:
>
> Hans Fangohr <fangohr.hans at gmail.com> writes:
>
>> Pete,
>>
>>> nbval provides a good way to test notebooks but my last questions
>>> still stand. Is TDD fundamentally a bad fit for Jupyter or is just
>>> that no-one has written a suitable implementation. If the latter then
>>> I might step up to the mark.
>>
>> Ah, I had missed that you core question was how to (wether?) use TDD
>> in Jupyter.
>>
>> I am certainly very interested in that question. I don’t think it is
>> clear that TDD is generally a bad fit for Jupyter - I’d rather think
>> nobody has explored this yet (or at least I haven’t heard about it),
>> both from a workflow and a tools perspective.
>>
>> What is your anticipated model here? Write the tests in a normal
>> python file, and develop in the notebook? Or have the tests in a
>> different notebook? Or something else?
>
> Either of your first two suggestions would work for me: test_foo.py or
> test_foo.ipynb to test foo.ipynb. I've played a bit with pytest-ipynb
> now and that does the latter. It can import Python modules and unit test
> them.
>
> What is needed is to import another notebook as the system under test. I
> have seen a length way of doing that and presume that it will either
> find its way into IPython or a package on PyPI.
>
> Because pytest-ipynb is using cells to hold its tests decorator based
> pytest features such as parameterize and xfail won't work.
I have just sketched another way of doing this where notebooks are converted to python files, and we run ‘conventional’ testing of converted python code. A worked example is at https://github.com/fangohr/tdd-with-jupyter .
If anybody is interested, we can extend this repo with more examples to gather different ways of doing TDD with jupyter.
Best wishes,
Hans
>
> --
> Pete Forman
> https://payg-petef.rhcloud.com
> (formerly on http://petef.22web.org/payg.html)
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
More information about the testing-in-python
mailing list