Skip to content

Commit

Permalink
Ensure testing framework is loaded only if dependencies are installed (
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv authored Sep 9, 2022
1 parent 81fcbcb commit 55f78d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
17 changes: 16 additions & 1 deletion webviz_config/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
from ._composite import WebvizComposite
from typing import Any, Generator

# pylint: disable=too-few-public-methods
class MissingWebvizTesting:
def __init__(self, **kwargs: Any) -> None:
raise RuntimeError(
"webviz_config[tests] was not installed. "
"Please install to use the webviz testing fixtures."
)


try:
from ._composite import WebvizComposite

except ImportError:
WebvizComposite = MissingWebvizTesting # type: ignore
15 changes: 1 addition & 14 deletions webviz_config/testing/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@

import pytest

# pylint: disable=too-few-public-methods
class MissingWebvizTesting:
def __init__(self, **kwargs: Any) -> None:
raise RuntimeError(
"webviz_config[tests] was not installed. "
"Please install to use the webviz testing fixtures."
)


try:
from webviz_config.testing._composite import WebvizComposite
except ImportError:

WebvizComposite = MissingWebvizTesting # type: ignore
from webviz_config.testing import WebvizComposite


@pytest.fixture
Expand Down

0 comments on commit 55f78d9

Please sign in to comment.