I have the following in my pyproject.toml
[tool.pytest.ini_options]
markers = [
"plot: marks SLOW plot tests (deselect with '-m \"not plot\"')",
"open_tutorial: marks the open_tutorial (which opens VSCode all the times)"
]
and I have a bunch of test methods marked accordingly.
If I run
coverage run --branch -m pytest -m "not open_tutorial"
or
coverage run --branch -m pytest -m "not plot"
I got the desired results, namely the marked test are skipped, but I cannot figure out how to make pytest to skip both.
I tried the following
coverage run --branch -m pytest -m "not open_tutorial" -m "not plot"
coverage run --branch -m pytest -m "not open_tutorial" "not plot"
coverage run --branch -m pytest -m ["not open_tutorial","not plot"]
but none of them worked.
According to pytest help:
-m MARKEXPR only run tests matching given mark expression. For example: -m 'mark1 and not mark2'.
If you want to use more than one marker you should use the and operator.
pytest -m "not open_tutorial and not plot"
will run all test without marks: open_tutorial and plot
but:
pytest -m "not open_tutorial and not plot and othermark"
will run tests with othermark if they don't have plot or open_tutorial marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With