Skip to content

Commit a7b1d4f

Browse files
committed
Skip the dash tests when Dash is not installed
1 parent 66c5e43 commit a7b1d4f

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/itables/dash.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
ITableOutputs,
66
__version__,
77
get_itable_component_kwargs,
8+
itables_for_dash_is_available,
89
updated_itable_outputs,
910
)
1011

@@ -15,5 +16,6 @@
1516
"get_itable_component_kwargs",
1617
"ITableOutputs",
1718
"updated_itable_outputs",
19+
"itables_for_dash_is_available",
1820
"__version__",
1921
]

src/itables_for_dash/__init__.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
from itables import __version__
22

3-
from .ITable import ITable as ITableComponent
3+
try:
4+
from .ITable import ITable as ITableComponent
5+
except (ImportError, ModuleNotFoundError) as e:
6+
import_error = e
7+
8+
class ITableComponent:
9+
def __init__(self, *args, **kwargs):
10+
raise import_error
11+
12+
itables_for_dash_is_available = False
13+
else:
14+
itables_for_dash_is_available = True
15+
416
from .properties import (
517
ITABLE_PROPERTIES,
618
ITableOutputs,

src/itables_for_dash/properties.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
from dash import Output, no_update
1+
try:
2+
from dash import Output, no_update
3+
except ImportError as e:
4+
import_error = e
5+
6+
def Output(*args, **kwargs):
7+
raise import_error
8+
9+
def no_update(*args, **kwargs):
10+
raise import_error
11+
212

313
from itables.javascript import get_itables_extension_arguments
414

tests/test_itables_for_dash.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import os
22
import sys
33

4-
from itables.dash import ITable, ITableComponent
4+
import pytest
5+
6+
from itables.dash import ITable, ITableComponent, itables_for_dash_is_available
7+
8+
if not itables_for_dash_is_available:
9+
pytestmark = pytest.mark.skip(reason="itables_for_dash is not available")
510

611

712
def check_ressource(relative_package_path, namespace, **kwargs):

0 commit comments

Comments
 (0)