Closed The-Compiler closed 3 years ago
Lately, I have been trying to to reduce the complexity of ipytest
and would prefer to not add new config options. TBH. I am almost in favor of complete removing the magic without cleaning and only keep %%run_pytest
that works like the current %%run_pytest[clean]
.
I do have to think about some more, but spontaneously, I think I would go with:
%%run_pytest[clean]
%%run_pytest
autoconfig(clean=False)
disable automatic cleaningclean
into clean_tests
as a default argument, so it does no longer depend on the configI think changing the magics is acceptable, as defining a new custom version is like three lines of code. Maybe adding a short how-to to the readme is enough.
That'd certainly work for me as well. While the cleaning is a bit of "magic", I guess it's the way people would expect ipytest to work usually - only running the current test, not anything that has been run before.
I understood, you maybe would like to give a stab? Otherwise I'll implement a prototype the coming days.
I went with %%ipytest
and removing the old magics. It is pre-released as ipytest==0.11.0b1
.
I'm still not sure, whether the mock %%run_pytest
and %%run_pytest[clean]
are good enough or whether I should keep the old functionality around for now to make upgrading easier.
See docs on the develop branch: https://github.com/chmp/ipytest/tree/develop
Thanks! Just used the prerelease to give a pytest training at Europython and it worked beautifully! :tada:
Sounds like perfect timing ;) Thanks for the feedback. Was there anything that did not work out or was unexpected?
I got an "unrecognized arguments" error from pytest once when trying to use --durations=5 --setup-show
or so, but later couldn't reproduce it - I suppose it was just a typo I didn't see at the time (unfortunately I did overwrite the original cell).
It took me a bit to realize that the error actually is coming from pytest, as it looks like this:
ERROR: usage: ipykernel_launcher.py [options] [file_or_dir] [file_or_dir] [...]
ipykernel_launcher.py: error: unrecognized arguments: --wrong
probably since sys.argv[0]
is ipykernel_launcher.py
rather than pytest
. I guess that's not specific to the prerelease though, and I'm not sure if there's anything that can be done about it anyways.
That is confusing :) I created a new ticket for it.
I fixed the progam name as well (using a small plugin) and released everything as 0.11.0
Before I open another pull request, I was wondering what you think about adding an
always_clean=True
option flag (False
by default) which makes%%run_pytest
equivalent to%%run_pytest[clean]
?For some context, I'd like to start using ipytest for the pytest trainings I teach, where the behavior of re-running all previous tests isn't very helpful - instead, for demos/exercises, only the current snippet is relevant usually.
Perhaps there could also be a
%%run_pytest[noclean]
(or[dirty]
or[continue]
or whatever?) to override the default when needeed.