diff --git a/.circleci/config.yml b/.circleci/config.yml index 072b75ed35..8748905290 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,7 +122,7 @@ jobs: command: | . venv/bin/activate && pip install --no-cache-dir --upgrade -e . --progress-bar off && mkdir packages cd dash-renderer && renderer build && python setup.py sdist && mv dist/* ../packages/ && cd .. - git clone --depth 1 https://github.com/plotly/dash-core-components.git + git clone --depth 1 -b import-test https://github.com/plotly/dash-core-components.git cd dash-core-components && npm ci && npm run build && python setup.py sdist && mv dist/* ../packages/ && cd .. ls -la packages - persist_to_workspace: diff --git a/dash/__init__.py b/dash/__init__.py index 647c457edd..a2afee8814 100644 --- a/dash/__init__.py +++ b/dash/__init__.py @@ -1,3 +1,4 @@ +__plotly_dash = True # for the "make sure you don't have a dash.py" check from .dash import Dash, no_update # noqa: F401 from . import dependencies # noqa: F401 from . import development # noqa: F401 diff --git a/package.json b/package.json index a39ad82e26..5aef8e9a94 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "private::test.R.deploy-nested": "npm run private::test.setup-nested && cd \\@plotly/dash-generator-test-component-nested && sudo R CMD INSTALL .", "private::test.R.deploy-standard": "npm run private::test.setup-standard && cd \\@plotly/dash-generator-test-component-standard && sudo R CMD INSTALL .", "private::test.unit-dash": "pytest tests/unit", + "private::test.unit-dash-import": "cd tests/unit/dash && python dash_import_test.py", "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}", "format": "run-s private::format.*", diff --git a/tests/unit/dash/dash_import_test.py b/tests/unit/dash/dash_import_test.py new file mode 100644 index 0000000000..6ab9b78868 --- /dev/null +++ b/tests/unit/dash/dash_import_test.py @@ -0,0 +1,17 @@ +# 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" diff --git a/tests/unit/dash/org.py b/tests/unit/dash/org.py new file mode 100644 index 0000000000..9cf7a3aeca --- /dev/null +++ b/tests/unit/dash/org.py @@ -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 diff --git a/tests/unit/dash/test_dash_import.py b/tests/unit/dash/test_dash_import.py deleted file mode 100644 index 35465fc7f5..0000000000 --- a/tests/unit/dash/test_dash_import.py +++ /dev/null @@ -1,14 +0,0 @@ -import importlib -import types - - -def test_dddi001_dash_import_is_correct(): - imported = importlib.import_module("dash") - assert isinstance(imported, types.ModuleType), "dash can be imported" - - with open("./dash/version.py") as fp: - assert imported.__version__ in fp.read(), "version is consistent" - - assert ( - getattr(imported, "Dash").__name__ == "Dash" - ), "access to main Dash class is valid" diff --git a/tests/unit/test_import.py b/tests/unit/test_import.py deleted file mode 100644 index 5448882471..0000000000 --- a/tests/unit/test_import.py +++ /dev/null @@ -1,14 +0,0 @@ -import importlib -import types - - -def test_dash_import_is_correct(): - imported = importlib.import_module("dash") - assert isinstance(imported, types.ModuleType), "dash can be imported" - - with open("./dash/version.py") as fp: - assert imported.__version__ in fp.read(), "version is consistent" - - assert ( - getattr(imported, "Dash").__name__ == "Dash" - ), "access to main Dash class is valid"