Using py.test, two tests called the same in different directory causes py.test to fail. Why is that? How can I change this without renaming all the tests?
To duplica
This is an actual feature of py.test. You can find the reason for this behavior stated in pytest.org - Good Integration Practices - Choosing a test layout / import rules:
- avoid
__init__.py
files in your test directories. This way your tests can run easily against an installed version ofmypkg
, independently from if the installed package contains the tests or not.
As that's the recommended workflow of working with py.test: install the package under development with pip install -e
, then test it.
Because of this, I myself opt for unique test names, in the convention over configuration manner. It also ensures that you don't get ambiguous test names in the various test run output.
If you need to keep the test names and don't care about the above mentioned functionality, you should be ok with putting an __init__.py
.