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
If you call pytest. fail inside a test, it's a FAIL status for that test (or XFAIL, if it has xfail mark). But, if you call it from a fixture, the test, which depends on this fixture, is getting ERROR state.
Run Multiple Tests From a Specific File and Multiple Files To run all the tests from all the files in the folder and subfolders we need to just run the pytest command. This will run all the filenames starting with test_ and the filenames ending with _test in that folder and subfolders under that folder.
The simplest way to skip a test function is to mark it with the skip decorator which may be passed an optional reason : @pytest. mark. skip(reason="no way of currently testing this") def test_the_unknown(): ...
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.
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