-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pytest functionality #2
Comments
I debated for a while between supporting unittest vs pytest at the beginning & mainly chose unittest because,
Anyhow, thinking more about it, there's no reason why treon shouldn't support pytest as well. So I'm going to work on it sometime in the next few weeks (unless someone else picks it up before that). Here's the rough implementation outline,
Let me know if there's a better way. |
I agree that unittest should definitely be supported for the reasons you gave and also because it is part of the standard library. Pytest seems to develop into somewhat of a successor to unittest, nose and other python test libraries. Additionally the syntax is easier to learn, e.g. def test_example():
assert [1, 2, 3] == [1, 2, 3] is just much simpler than what unittest offers. To implement it I think think your route sounds good. There are also the ipytest and nbval projects which slightly overlap in functionality. I don't know if including either of these would make the integration of pytest into treon easier though. |
I had looked at ipytest earlier and it's mainly geared for running pytest as a cell magic from the Jupyter environment itself. Nothing wrong with it just wouldn't integrate well with treon's command line approach. Probably best to directly use nbconvert (for ipynb to py) and py.test so we can access the test result (success/failure) and integrate it into treon result summary etc. Aside: |
There is. You parse the cells - and then run them. There is an old way that uses And there is the modern approach, https://www.blog.pythonlibrary.org/2018/10/16/testing-jupyter-notebooks/ May be you could take over pytest-ipynb and integrate treon into it (or the other way around), I am not attached. I've been trying to summarize the existing approaches here: https://github.com/stas00/pytest-ipynb/blob/master/ipynb-testing-ways.md - please send me a PM to add treon. p.s. Kudos on all the great work with reviewnb and now treon, Amit! |
Just learned of treon from https://github.com/markusschanta/awesome-jupyter/blob/master/README.md#testing ; which currently lists:
|
Combining Jupyter notebooks with test driven development feels great, treon is really helpful for CI pipelines. Is it possible besides doctest and unittest to also include the pytest framework?
It seems that pytest does not have a drop-in function such as the unittest.main() which executes the current module but requires a filename. Still this would be a nice addition and removes a lot of boilerplate one needs for the unittest framework.
The text was updated successfully, but these errors were encountered: