Skip to content

Commit 2fec0b2

Browse files
committed
update test
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 7ab8167 commit 2fec0b2

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Diff for: packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
import pandas as pd
55
import pytest
6+
import unittest.mock as mock
67
from plotly.express._core import build_dataframe
78
from pandas.testing import assert_frame_equal
89

@@ -233,17 +234,22 @@ def test_build_df_with_index():
233234
assert_frame_equal(tips.reset_index()[out["data_frame"].columns], out["data_frame"])
234235

235236

236-
def test_build_df_protocol():
237-
import vaex
237+
def test_build_df_using_interchange_protocol_mock():
238+
class CustomDataFrame:
239+
def __dataframe__(self):
240+
pass
238241

239-
# take out the 'species' columns since there are still some issues with strings
240-
iris_pandas = px.data.iris()[["petal_width", "sepal_length"]]
241-
iris_vaex = vaex.from_pandas(iris_pandas)
242-
args = dict(data_frame=iris_vaex, x="petal_width", y="sepal_length")
243-
out = build_dataframe(args, go.Scatter)
244-
assert_frame_equal(
245-
iris_pandas.reset_index()[out["data_frame"].columns], out["data_frame"]
246-
)
242+
input_dataframe = CustomDataFrame()
243+
args = dict(data_frame=input_dataframe, x="petal_width", y="sepal_length")
244+
245+
iris_pandas = px.data.iris()
246+
247+
with mock.patch("pandas.__version__", "2.0.2"):
248+
with mock.patch(
249+
"pandas.api.interchange.from_dataframe", return_value=iris_pandas
250+
) as mock_from_dataframe:
251+
build_dataframe(args, go.Scatter)
252+
mock_from_dataframe.assert_called_once_with(input_dataframe)
247253

248254

249255
def test_timezones():

0 commit comments

Comments
 (0)