When a python module has multiple subpackages, where should tests for features in those subpackages be placed?
I can see two ways it could be done:
- Create a separate
test
folder in each subpackage and place its tests there. - Duplicate the package hierarchy in the top-level
test
folder, placing the tests for each subpackage in the corresponding folder.
However it's not clear which option should be preferred.
For a package foo
arranged like this:
foo/
__init__.py
bar.py
baz/
__init__.py
baz.py
Do I put the tests here?
foo/
__init__.py
bar.py
baz/
__init__.py
baz.py
test/
__init__.py
test_bar.py
baz/
__init__.py
test_baz.py
Or here?
foo/
__init__.py
bar.py
baz/
__init__.py
baz.py
test/
__init__.py
test_baz.py
test/
__init__.py
test_bar.py
Aucun commentaire:
Enregistrer un commentaire