dash-testing-stub Library
dash-testing-stub is a lightweight Python package, currently at version 0.0.2. Its sole purpose is to serve as a marker or stub dependency within the `dash[testing]` extra, signaling the availability for optional loading of the `pytest-dash` plugin. It is not intended for direct user import or interaction, acting purely as an internal mechanism for conditional feature enablement in Dash testing environments. It is released as part of the official Dash framework.
Common errors
-
ImportError: cannot import name 'SomeFunction' from 'dash_testing_stub' (unknown location)
cause Attempting to import a non-existent function or class from the `dash-testing-stub` package.fixThe `dash-testing-stub` package is an empty marker package and contains no exportable symbols. Remove any `from dash_testing_stub import ...` statements from your code. If you need Dash testing tools, ensure you've installed `dash[testing]` and use the `pytest-dash` plugin features. -
AttributeError: module 'dash_testing_stub' has no attribute 'some_method'
cause Mistakenly treating `dash_testing_stub` as a module that provides functions or objects after importing it.fixThe `dash-testing-stub` module is empty and does not expose any attributes or methods. It exists purely as a dependency marker. Do not attempt to access attributes on it. Install `dash[testing]` and refer to the `pytest-dash` documentation for how to use Dash's testing fixtures.
Warnings
- gotcha Do not attempt to import specific symbols or functionalities from `dash-testing-stub`. It is an empty stub package and contains no Python code beyond its `__init__.py` (which is empty). Its purpose is solely to act as a flag for the `dash[testing]` extra.
- gotcha Installing `dash-testing-stub` directly via `pip install dash-testing-stub` will not provide the full testing suite. It only installs the empty stub package. The complete `pytest-dash` plugin and related tools are part of the `dash[testing]` extra.
- gotcha This package is an internal dependency of Dash's testing infrastructure. It is not designed for independent use or extension.
Install
-
pip install dash[testing] -
pip install dash-testing-stub
Imports
- *
from dash_testing_stub import SomeSymbol
This package is not meant for direct import.
Quickstart
# 1. Install Dash with testing extras:
# pip install dash[testing]
# 2. Create a test file (e.g., test_app.py):
import dash
from dash import html
import pytest
@pytest.fixture
def dash_app():
app = dash.Dash(__name__)
app.layout = html.Div([html.H1("Hello Dash Testing!"), html.Div(id='output-div')])
return app
def test_initial_layout(dash_duo, dash_app):
dash_duo.start_server(dash_app)
dash_duo.wait_for_text_to_equal("h1", "Hello Dash Testing!", timeout=4)
assert dash_duo.driver.find_element_by_tag_name("h1").text == "Hello Dash Testing!"
# 3. Run pytest from your terminal in the same directory:
# pytest