Skip to content

Commit 495f794

Browse files
authored
Merge pull request #2187 from plotly/testing-import-error
Improve error message when using fixtures but testing not installed.
2 parents 20b6467 + de5cd9d commit 495f794

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
### Fixed
88

99
- [#2152](https://github.com/plotly/dash/pull/2152) Fix bug [#2128](https://github.com/plotly/dash/issues/2128) preventing rendering of multiple components inside a dictionary.
10+
- [#2187](https://github.com/plotly/dash/pull/2187) Fix confusing error message when trying to use pytest fixtures but `dash[testing]` is not installed.
1011

1112
## [2.6.1] - 2022-08-01
1213

Diff for: dash/testing/plugin.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# pylint: disable=missing-docstring,redefined-outer-name
2-
from typing import Any
3-
42
import pytest
53
from .consts import SELENIUM_GRID_DEFAULT
64

75

6+
# pylint: disable=too-few-public-methods
7+
class MissingDashTesting:
8+
def __init__(self, **kwargs):
9+
raise Exception(
10+
"dash[testing] was not installed. "
11+
"Please install to use the dash testing fixtures."
12+
)
13+
14+
815
try:
916
from dash.testing.application_runners import (
1017
ThreadedRunner,
@@ -17,15 +24,15 @@
1724
from dash.testing.composite import DashComposite, DashRComposite, DashJuliaComposite
1825
except ImportError:
1926
# Running pytest without dash[testing] installed.
20-
ThreadedRunner = Any
21-
ProcessRunner = Any
22-
MultiProcessRunner = Any
23-
RRunner = Any
24-
JuliaRunner = Any
25-
Browser = Any
26-
DashComposite = Any
27-
DashRComposite = Any
28-
DashJuliaComposite = Any
27+
ThreadedRunner = MissingDashTesting
28+
ProcessRunner = MissingDashTesting
29+
MultiProcessRunner = MissingDashTesting
30+
RRunner = MissingDashTesting
31+
JuliaRunner = MissingDashTesting
32+
Browser = MissingDashTesting
33+
DashComposite = MissingDashTesting
34+
DashRComposite = MissingDashTesting
35+
DashJuliaComposite = MissingDashTesting
2936

3037

3138
def pytest_addoption(parser):

0 commit comments

Comments
 (0)