|
1 | 1 | import pandas as pd |
2 | 2 | import plotly.graph_objects as go |
| 3 | +import pytest |
3 | 4 |
|
4 | 5 | from plotly_resampler import FigureResampler, FigureWidgetResampler |
5 | 6 | from plotly_resampler.figure_resampler.utils import ( |
|
13 | 14 | ) |
14 | 15 |
|
15 | 16 |
|
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) |
28 | 43 |
|
29 | 44 |
|
30 | 45 | def test_is_fr(): |
|
0 commit comments