New issue 529: "unique basename" and __init__.py docs
https://bitbucket.org/hpk42/pytest/issue/529/unique-basename-and-__init__py-docs

Thomas Güttler:

Our tests don't have unique basenames, since we use this pattern:

The tests for admin.py is located in tests/unit/test_admin.py

There are several apps in one project which have an admin.py.

This way we get the well known error message:
```
import file mismatch:
imported module 'test_admin' has this __file__ attribute:
  foo/tests/unit/views/test_admin.py
which is not the same as the test file we want to collect:
 bar/tests/unit/test_admin.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your 
test file modules
```

Our current solution is to create `__init__.py` files.

This is against the docs:

*avoid “__init__.py” files in your test directories. This way your tests can 
run easily against an installed version of mypkg, independently from the 
installed package if it contains the tests or not.
*

Please think about this again. For me, the constraint to have unique base names 
way to hard. 

Maybe the best solution is to update the docs:

*If you avoid __init__.py files you can ....*

I don't think every one should avoid `__init__.py` files.



_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to