Skip to content

Commit

Permalink
Merge pull request #1493 from plotly/import-test
Browse files Browse the repository at this point in the history
improve dash import test
  • Loading branch information
alexcjohnson authored Dec 10, 2020
2 parents 2fa1883 + a06e12b commit cd2ff7c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]
### Fixed
- [#1493](https://github.com/plotly/dash/pull/1493) Fix [#1143](https://github.com/plotly/dash/issues/1143), a bug where having a file with one of several common names (test.py, code.py, org.py, etc) that imports a dash component package would make `import dash` fail with a cryptic error message asking whether you have a file named "dash.py"

## [1.18.1] - 2020-12-09

## [1.18.0] - 2020-12-07
Expand Down
18 changes: 11 additions & 7 deletions dash/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from .dash import Dash, no_update # noqa: F401
from . import dependencies # noqa: F401
from . import development # noqa: F401
from . import exceptions # noqa: F401
from . import resources # noqa: F401
from .version import __version__ # noqa: F401
from ._callback_context import callback_context # noqa: F401
# pylint: disable=C0413
# __plotly_dash is for the "make sure you don't have a dash.py" check
# must come before any other imports.
__plotly_dash = True
from .dash import Dash, no_update # noqa: F401,E402
from . import dependencies # noqa: F401,E402
from . import development # noqa: F401,E402
from . import exceptions # noqa: F401,E402
from . import resources # noqa: F401,E402
from .version import __version__ # noqa: F401,E402
from ._callback_context import callback_context # noqa: F401,E402
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"private::test.unit-dash": "pytest tests/unit",
"private::test.unit-renderer": "cd dash-renderer && npm run test",
"private::test.integration-dash": "TESTFILES=$(circleci tests glob \"tests/integration/**/test_*.py\" | circleci tests split --split-by=timings) && pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml ${TESTFILES}",
"private::test.integration-dash-import": "cd tests/integration/dash && python dash_import_test.py",
"format": "run-s private::format.*",
"initialize": "run-s private::initialize.*",
"lint": "run-s private::lint.*",
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/dash/dash_import_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NOTE: this is NOT a pytest test. Just run it as a regular Python script.
# pytest does some magic that makes the issue we're trying to test disappear.

import types
import os

import dash

assert isinstance(dash, types.ModuleType), "dash can be imported"

this_dir = os.path.dirname(__file__)
with open(os.path.join(this_dir, "../../../dash/version.py")) as fp:
assert dash.__version__ in fp.read(), "version is consistent"

assert getattr(dash, "Dash").__name__ == "Dash", "access to main Dash class is valid"
3 changes: 3 additions & 0 deletions tests/integration/dash/org.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# used implicitly by dash_import_test
# to test https://github.com/plotly/dash/issues/1143
import dash_core_components as dcc # noqa: F401
14 changes: 0 additions & 14 deletions tests/unit/dash/test_dash_import.py

This file was deleted.

14 changes: 0 additions & 14 deletions tests/unit/test_import.py

This file was deleted.

0 comments on commit cd2ff7c

Please sign in to comment.