Skip to content

Commit 6c41be3

Browse files
authored
Merge pull request #328 from ivanovmg/fix/parametrize-tests
Parametrize test_utils.py on is_figure
2 parents bfc3d8b + 4f015d3 commit 6c41be3

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

tests/test_utils.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pandas as pd
22
import plotly.graph_objects as go
3+
import pytest
34

45
from plotly_resampler import FigureResampler, FigureWidgetResampler
56
from plotly_resampler.figure_resampler.utils import (
@@ -13,18 +14,32 @@
1314
)
1415

1516

16-
def test_is_figure():
17-
fig_dict = {"type": "scatter", "y": [1, 2, 3]}
18-
assert is_figure(go.Figure())
19-
assert is_figure(go.Figure(fig_dict))
20-
assert is_figure(FigureResampler())
21-
assert is_figure(FigureResampler(fig_dict))
22-
assert not is_figure(go.FigureWidget())
23-
assert not is_figure(None)
24-
assert not is_figure(fig_dict)
25-
assert not is_figure(go.Scatter(y=[1, 2, 3]))
26-
assert not is_figure(FigureWidgetResampler())
27-
assert not is_figure(FigureWidgetResampler(fig_dict))
17+
@pytest.mark.parametrize(
18+
"obj",
19+
[
20+
go.Figure(),
21+
go.Figure({"type": "scatter", "y": [1, 2, 3]}),
22+
FigureResampler(),
23+
FigureResampler({"type": "scatter", "y": [1, 2, 3]}),
24+
],
25+
)
26+
def test_is_figure(obj):
27+
assert is_figure(obj)
28+
29+
30+
@pytest.mark.parametrize(
31+
"obj",
32+
[
33+
go.FigureWidget(),
34+
None,
35+
{"type": "scatter", "y": [1, 2, 3]},
36+
go.Scatter(y=[1, 2, 3]),
37+
FigureWidgetResampler(),
38+
FigureWidgetResampler({"type": "scatter", "y": [1, 2, 3]}),
39+
],
40+
)
41+
def test_not_is_figure(obj):
42+
assert not is_figure(obj)
2843

2944

3045
def test_is_fr():

0 commit comments

Comments
 (0)