dash icon indicating copy to clipboard operation
dash copied to clipboard

[BUG] pytest plugin breaks tests with __init__.py files

Open bmerry opened this issue 4 years ago • 0 comments

Thank you so much for helping improve the quality of Dash!

We do our best to catch bugs during the release process, but we rely on your help to find the ones that slip through.

Describe your context

dash-core-components 0.47.0
dash-html-components 0.16.0
dash-renderer        0.23.0
dash-table           3.6.0

Describe the bug

When dash is installed, it seems to alter how pytest sets up sys.path for tests. If a test directory is arranged as a package (with __init__.py files, it seems to prevent the root of the package from being added to sys.path.

To reproduce, create a directory with the following empty files:

└── test
    ├── conftest.py
    └── __init__.py

Create a virtual environment with just pytest and dash. Run pytest (in the parent of test).

Note that this doesn't require dash to be imported anywhere; simply having it installed in the environment is enough to break pytest.

Expected behavior

Without dash installed, the following is output:

============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/bmerry/work/sdp/bugs/dash-breaks-pytest
collected 0 items                                                              

============================ no tests ran in 0.00s =============================

With dash installed, the output is:

ImportError while loading conftest '/home/bmerry/work/sdp/bugs/dash-breaks-pytest/test/conftest.py'.
ModuleNotFoundError: No module named 'test.conftest'

bmerry avatar Jul 21 '21 09:07 bmerry