Matan Bakshi
Matan Bakshi

Reputation: 183

Running a single test method with pytest fails (not found)

I am trying to run a specific test method with pytest on Python 3.6 with the following command:

pytest sanity_test.py::test_check

(as mentioned in pytest docs)

and it fails with the following error message:

ERROR: not found: <rootdir>/tests/automation/sanity/sanity_test.py::test_check
(no name '<rootdir>/tests/automation/sanity/sanity_test.py::test_check' in any of [<DoctestModule 'tests/automation/sanity/sanity_test.py'>, <Module 
'tests/automation/sanity/sanity_test.py'>])

when I run the whole test file the tests are running properly with:

pytest sanity_test.py

When I tried running a specific method in isolated project it works perfectly.

Any reason why pytest can't find specifically my test methods on my project?

The file is very simple and looks like this:

def test_check():
    pass

Upvotes: 10

Views: 4304

Answers (1)

Matan Bakshi
Matan Bakshi

Reputation: 183

Thank to hoefling, I recognized that I had --doctest-modules option in my setup.cfg file. Removing this option fixed the problem. hoefling opened an issue in pytest for that problem.

Upvotes: 3

Related Questions