Skip to content

Commit 6948173

Browse files
committed
improve dash import test
see #1143
1 parent 2fa1883 commit 6948173

File tree

7 files changed

+31
-36
lines changed

7 files changed

+31
-36
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
command: |
123123
. venv/bin/activate && pip install --no-cache-dir --upgrade -e . --progress-bar off && mkdir packages
124124
cd dash-renderer && renderer build && python setup.py sdist && mv dist/* ../packages/ && cd ..
125-
git clone --depth 1 https://github.com/plotly/dash-core-components.git
125+
git clone --depth 1 -b import-test https://github.com/plotly/dash-core-components.git
126126
cd dash-core-components && npm ci && npm run build && python setup.py sdist && mv dist/* ../packages/ && cd ..
127127
ls -la packages
128128
- persist_to_workspace:

Diff for: dash/__init__.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
from .dash import Dash, no_update # noqa: F401
2-
from . import dependencies # noqa: F401
3-
from . import development # noqa: F401
4-
from . import exceptions # noqa: F401
5-
from . import resources # noqa: F401
6-
from .version import __version__ # noqa: F401
7-
from ._callback_context import callback_context # noqa: F401
1+
# pylint: disable=C0413
2+
# __plotly_dash is for the "make sure you don't have a dash.py" check
3+
# must come before any other imports.
4+
__plotly_dash = True
5+
from .dash import Dash, no_update # noqa: F401,E402
6+
from . import dependencies # noqa: F401,E402
7+
from . import development # noqa: F401,E402
8+
from . import exceptions # noqa: F401,E402
9+
from . import resources # noqa: F401,E402
10+
from .version import __version__ # noqa: F401,E402
11+
from ._callback_context import callback_context # noqa: F401,E402

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"private::test.unit-dash": "pytest tests/unit",
2323
"private::test.unit-renderer": "cd dash-renderer && npm run test",
2424
"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}",
25+
"private::test.integration-dash-import": "cd tests/integration/dash && python dash_import_test.py",
2526
"format": "run-s private::format.*",
2627
"initialize": "run-s private::initialize.*",
2728
"lint": "run-s private::lint.*",

Diff for: tests/integration/dash/dash_import_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# NOTE: this is NOT a pytest test. Just run it as a regular Python script.
2+
# pytest does some magic that makes the issue we're trying to test disappear.
3+
4+
import types
5+
import os
6+
7+
import dash
8+
9+
assert isinstance(dash, types.ModuleType), "dash can be imported"
10+
11+
this_dir = os.path.dirname(__file__)
12+
with open(os.path.join(this_dir, "../../../dash/version.py")) as fp:
13+
assert dash.__version__ in fp.read(), "version is consistent"
14+
15+
assert getattr(dash, "Dash").__name__ == "Dash", "access to main Dash class is valid"

Diff for: tests/integration/dash/org.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# used implicitly by dash_import_test
2+
# to test https://github.com/plotly/dash/issues/1143
3+
import dash_core_components as dcc # noqa: F401

Diff for: tests/unit/dash/test_dash_import.py

-14
This file was deleted.

Diff for: tests/unit/test_import.py

-14
This file was deleted.

0 commit comments

Comments
 (0)