pythonpytestgoogle-maps-markerspytest-djangopytest-cov

How to fix pytest marker not picking up tests


I have my tests at src/com/xyz/tests/bla_tests/file1.py. I also have file2.py at that path.

I have the following code in file1.py

class HelloWorld():
    @pytest.mark.regressiontest
    def test_001_bla?():
        # Some code here. 

From command line I invoke the test by :

pytest -v -m regressiontest 

but no items are collected. It says : collected 0 items.

My aim is to mark multiple tests across various files as regressiontest and be able to run them from the Command line. (On Mac). The following command is able to collect the tests though

pytest -q file1.py -v -m regressiontest 

This says: collected 20 items / 11 deselected / 9 selected     

Can someone help me out?


Solution

  • Got the resolution here:

    pytest by default doesn't look for tests in files not named like test_*.py

    also using --basetemp=. actually does a rm -rf . so that's def not a good idea, we should warn about that

    In my case, my file name was not starting from test_*