Skip to content

Commit

Permalink
Disable testing plugin options if dash[testing] not installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Feb 8, 2023
1 parent 8ffb331 commit e48674a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dash/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, **kwargs):
)
from dash.testing.browser import Browser
from dash.testing.composite import DashComposite, DashRComposite, DashJuliaComposite
_installed = True
except ImportError:
# Running pytest without dash[testing] installed.
ThreadedRunner = MissingDashTesting
Expand All @@ -33,9 +34,13 @@ def __init__(self, **kwargs):
DashComposite = MissingDashTesting
DashRComposite = MissingDashTesting
DashJuliaComposite = MissingDashTesting
_installed = False


def pytest_addoption(parser):
if not _installed:
return

dash = parser.getgroup("Dash", "Dash Integration Tests")

dash.addoption(
Expand Down Expand Up @@ -82,6 +87,8 @@ def pytest_addoption(parser):

@pytest.mark.tryfirst
def pytest_addhooks(pluginmanager):
if not _installed:
return
# https://github.com/pytest-dev/pytest-xdist/blob/974bd566c599dc6a9ea291838c6f226197208b46/xdist/plugin.py#L67
# avoid warnings with pytest-2.8
from dash.testing import newhooks # pylint: disable=import-outside-toplevel
Expand All @@ -94,6 +101,8 @@ def pytest_addhooks(pluginmanager):

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call): # pylint: disable=unused-argument
if not _installed:
return
# execute all other hooks to obtain the report object
outcome = yield
rep = outcome.get_result()
Expand Down

0 comments on commit e48674a

Please sign in to comment.