Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve dash import test #1493

Merged
merged 3 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
cd dash-core-components && npm ci && npm run build && python setup.py sdist && mv dist/* ../packages/ && cd ..
ls -la packages
- persist_to_workspace:
Expand Down
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.