From 2cd87ccbcd1ef68c8d6c48ff418eb2291290282c Mon Sep 17 00:00:00 2001 From: philippe Date: Tue, 9 Aug 2022 12:02:35 -0400 Subject: [PATCH 1/2] Improve error message when using fixtures but testing not installed. --- dash/testing/plugin.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/dash/testing/plugin.py b/dash/testing/plugin.py index 4265589259..20eb26dffe 100644 --- a/dash/testing/plugin.py +++ b/dash/testing/plugin.py @@ -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, @@ -16,14 +23,14 @@ from dash.testing.composite import DashComposite, DashRComposite, DashJuliaComposite except ImportError: # Running pytest without dash[testing] installed. - ThreadedRunner = Any - ProcessRunner = Any - RRunner = Any - JuliaRunner = Any - Browser = Any - DashComposite = Any - DashRComposite = Any - DashJuliaComposite = Any + ThreadedRunner = MissingDashTesting + ProcessRunner = MissingDashTesting + RRunner = MissingDashTesting + JuliaRunner = MissingDashTesting + Browser = MissingDashTesting + DashComposite = MissingDashTesting + DashRComposite = MissingDashTesting + DashJuliaComposite = MissingDashTesting def pytest_addoption(parser): From de5cd9d7d640c8a39c7df3d0705ca77127b726b1 Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 12 Aug 2022 14:39:34 -0400 Subject: [PATCH 2/2] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c01cd93a..54bb6d4df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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