Skip to content

Commit 549140e

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

File tree

7 files changed

+23
-29
lines changed

7 files changed

+23
-29
lines changed

.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:

dash/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# __plotly_dash = True # for the "make sure you don't have a dash.py" check
12
from .dash import Dash, no_update # noqa: F401
23
from . import dependencies # noqa: F401
34
from . import development # noqa: F401

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"private::test.R.deploy-nested": "npm run private::test.setup-nested && cd \\@plotly/dash-generator-test-component-nested && sudo R CMD INSTALL .",
2121
"private::test.R.deploy-standard": "npm run private::test.setup-standard && cd \\@plotly/dash-generator-test-component-standard && sudo R CMD INSTALL .",
2222
"private::test.unit-dash": "pytest tests/unit",
23+
"private::test.unit-dash-import": "cd tests && python dash_import_test.py",
2324
"private::test.unit-renderer": "cd dash-renderer && npm run test",
2425
"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}",
2526
"format": "run-s private::format.*",

tests/unit/dash/dash_import_test.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 (
16+
getattr(dash, "Dash").__name__ == "Dash"
17+
), "access to main Dash class is valid"

tests/unit/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

tests/unit/dash/test_dash_import.py

-14
This file was deleted.

tests/unit/test_import.py

-14
This file was deleted.

0 commit comments

Comments
 (0)