-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Bug Report
Description
Modules named test_XXX.py have a special meaning for pytest and are handled as test files, which causes some weird side-effects with our dvc.testing.test_XXX modules:
- A minor one is that they get collected as test files if you run
pytest dvceven though they're meant to run that way. - More annoying: whenever they're imported from a test (even in a different project), pytest creates cache files next to them, potentially polluting
site-packageswith files thatpip uninstallwon't remove.
Reproduce
In a fresh virtualenv:
(dvc-s3) ronan@Creizic iterative % cd dvc-s3
(dvc-s3) ronan@Creizic dvc-s3 % pip install -e ".[tests]"
...
(dvc-s3) ronan@Creizic dvc-s3 % pytest dvc_s3
<SUCCESS>
(dvc-s3) ronan@Creizic dvc-s3 % ls /Users/ronan/.pyenv/versions/dvc-s3/lib/python3.8/site-packages/dvc/testing/__pycache__
__init__.cpython-38.pyc test_api.cpython-38.pyc
cloud.cpython-38.pyc test_remote.cpython-38-pytest-6.2.5.pyc
conftest.cpython-38.pyc test_remote.cpython-38.pyc
fixtures.cpython-38.pyc test_workspace.cpython-38-pytest-6.2.5.pyc
path_info.cpython-38.pyc test_workspace.cpython-38.pyc
test_api.cpython-38-pytest-6.2.5.pyc tmp_dir.cpython-38.pyc
(dvc-s3) ronan@Creizic dvc-s3 % cd ../dvc
(dvc-s3) ronan@Creizic dvc % pip install -e .
...
(dvc-s3) ronan@Creizic dvc % cd -
(dvc-s3) ronan@Creizic dvc-s3 % ls /Users/ronan/.pyenv/versions/dvc-s3/lib/python3.8/site-packages/dvc/testing/__pycache__
test_api.cpython-38-pytest-6.2.5.pyc test_workspace.cpython-38-pytest-6.2.5.pyc
test_remote.cpython-38-pytest-6.2.5.pyc
(dvc-s3) ronan@Creizic dvc-s3 % pytest dvc_s3
...
FAILED dvc_s3/tests/test_dvc.py::TestImport::test_import - AttributeError: module 'logging' has no attribute 'TRACE'
...
Note: the test failures happen because SITE-PACKAGES/dvc still exists (containing only the pytest cache files), which turns dvc into a namespace package, which causes dvc.__init__ not to be executed when importing dvc.
Metadata
Metadata
Assignees
Labels
No labels