Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytest --collect-only -q to ignore tests that skip

Tags:

pytest

I am working with pytest and I need to collect test cases. For this there exists the following command:

pytest --collect-only -q

I am only interested in the tests that would be actually executed, if I would perform for example:

pytest tests/my_tests

(and not the skipped ones). How can I avoid collecting the tests that would skip?

like image 353
Lukas Avatar asked Sep 02 '25 05:09

Lukas


1 Answers

Invoke the mark filter on the command line:

pytest --collect-only -q -m "not skip"

This avoids having to create or modify a conftest.py file.

like image 98
Billy Avatar answered Sep 04 '25 23:09

Billy