[TIP] PyTest + Tox: Ignoring tests based on command line options.
me at the-compiler.org
Thu Nov 21 09:05:24 PST 2019
On Thu, Nov 21, 2019 at 05:57:57PM +0100, Daniel Knüttel wrote:
> Hi, Folks.
> Basically what I have is a big bunch of small tests that I want to
> run all the time. Those are pretty fast & handwritten to test specific
> features. I also have some random tests that take a long time to run
> (2000 10-qbit circuits of length 100 for instance).
> I need those tests to ensure my library works as intended, but I dont
> want to wait a minute for my tests to run when I am just testing one
> So I marked my slow tests with @pytest.mark.slow and added
> '-m "not slow"' in my tox.ini. Which works fine unless I do want to run
> the tests, in which case I would have to rewrite my tox.ini.
> Is there a way to run the tests if I pass some argument to tox?
> like 'tox -m "with slow"'?
You can add a custom commandline option to your testsuite, pretty much exactly
like the example here:
Then you could run without that argument by default, but run with `tox --
--runslow` if you do want to run them.
Alternatively, you could define two different tox environments, one running
with `-m "not slow"`, one without. Then use e.g. either `tox` or `tox -e slow`.
https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 833 bytes
Desc: not available
More information about the testing-in-python