ca9163d9
ca9163d9

Reputation: 29159

Why pytest deselect all the tests when run with python -m test?

I can run my tests by executing (on Windows)

pytest .\tests\test_x.py

Result:

================================= test session starts ==================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\......
collected 9 items

tests\test_x.py .........                                                         [100%]

================================== 9 passed in 3.67s ===================================

However, the following two commands

pytest -m tests
pytest -m test

got the following result. Why all the tests are deselected while they can be run as script?

PS C:\Users\......> pytest -m test
================================= test session starts ==================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\......
collected 9 items / 9 deselected

================================ 9 deselected in 3.78s =================================

Upvotes: 6

Views: 6132

Answers (1)

Tordek
Tordek

Reputation: 10872

You're using -m which filters which tests to run according to how you mark your tests. You're telling pytest to only run tests tagged @pytest.mark.test.

Presumably, you don't have any tests marked as such.

https://docs.pytest.org/en/stable/example/markers.html#mark-run

Upvotes: 5

Related Questions