Skip to content

Commit

Permalink
Merge pull request #2187 from plotly/testing-import-error
Browse files Browse the repository at this point in the history
Improve error message when using fixtures but testing not installed.
  • Loading branch information
T4rk1n authored Aug 15, 2022
2 parents 20b6467 + de5cd9d commit 495f794
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Fixed

- [#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.
- [#2187](https://github.com/plotly/dash/pull/2187) Fix confusing error message when trying to use pytest fixtures but `dash[testing]` is not installed.

## [2.6.1] - 2022-08-01

Expand Down
29 changes: 18 additions & 11 deletions dash/testing/plugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# pylint: disable=missing-docstring,redefined-outer-name
from typing import Any

import pytest
from .consts import SELENIUM_GRID_DEFAULT


# pylint: disable=too-few-public-methods
class MissingDashTesting:
def __init__(self, **kwargs):
raise Exception(
"dash[testing] was not installed. "
"Please install to use the dash testing fixtures."
)


try:
from dash.testing.application_runners import (
ThreadedRunner,
Expand All @@ -17,15 +24,15 @@
from dash.testing.composite import DashComposite, DashRComposite, DashJuliaComposite
except ImportError:
# Running pytest without dash[testing] installed.
ThreadedRunner = Any
ProcessRunner = Any
MultiProcessRunner = Any
RRunner = Any
JuliaRunner = Any
Browser = Any
DashComposite = Any
DashRComposite = Any
DashJuliaComposite = Any
ThreadedRunner = MissingDashTesting
ProcessRunner = MissingDashTesting
MultiProcessRunner = MissingDashTesting
RRunner = MissingDashTesting
JuliaRunner = MissingDashTesting
Browser = MissingDashTesting
DashComposite = MissingDashTesting
DashRComposite = MissingDashTesting
DashJuliaComposite = MissingDashTesting


def pytest_addoption(parser):
Expand Down

0 comments on commit 495f794

Please sign in to comment.