Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrize test_utils.py on is_figure #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import plotly.graph_objects as go
import pytest

from plotly_resampler import FigureResampler, FigureWidgetResampler
from plotly_resampler.figure_resampler.utils import (
Expand All @@ -13,18 +14,32 @@
)


def test_is_figure():
fig_dict = {"type": "scatter", "y": [1, 2, 3]}
assert is_figure(go.Figure())
assert is_figure(go.Figure(fig_dict))
assert is_figure(FigureResampler())
assert is_figure(FigureResampler(fig_dict))
assert not is_figure(go.FigureWidget())
assert not is_figure(None)
assert not is_figure(fig_dict)
assert not is_figure(go.Scatter(y=[1, 2, 3]))
assert not is_figure(FigureWidgetResampler())
assert not is_figure(FigureWidgetResampler(fig_dict))
@pytest.mark.parametrize(
"obj",
[
go.Figure(),
go.Figure({"type": "scatter", "y": [1, 2, 3]}),
FigureResampler(),
FigureResampler({"type": "scatter", "y": [1, 2, 3]}),
],
)
def test_is_figure(obj):
assert is_figure(obj)


@pytest.mark.parametrize(
"obj",
[
go.FigureWidget(),
None,
{"type": "scatter", "y": [1, 2, 3]},
go.Scatter(y=[1, 2, 3]),
FigureWidgetResampler(),
FigureWidgetResampler({"type": "scatter", "y": [1, 2, 3]}),
],
)
def test_not_is_figure(obj):
assert not is_figure(obj)


def test_is_fr():
Expand Down
Loading