Skip to content
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

FEATURE: Builtin pytest magic #3456

Open
pylang opened this issue Mar 21, 2018 · 3 comments
Open

FEATURE: Builtin pytest magic #3456

pylang opened this issue Mar 21, 2018 · 3 comments

Comments

@pylang
Copy link

pylang commented Mar 21, 2018

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?

@chmp
Copy link

chmp commented Sep 30, 2018

Maybe of interest: I wrote a small package ipytest, which allows to run tests defined inside notebooks.

@pylang
Copy link
Author

pylang commented Oct 1, 2018

@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. ))

@chmp
Copy link

chmp commented Oct 1, 2018

@pylang Thanks a lot for the feedback. I understand your comment to have two parts:

  • "global state handling is sup-optimal": I feel this issue is deeply tied to the notebook model and I don't see a simple way out. Deleting all old tests worked for me so far.
  • "assertion rewriting via magics is cumbersome": I fully agree. The newest 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants