Skip to content

Commit

Permalink
add fixture
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Jun 12, 2023
1 parent 2fec0b2 commit 9b2154e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
from plotly.express._core import build_dataframe
from pandas.testing import assert_frame_equal

# Fixtures
# --------
@pytest.fixture
def add_interchange_module_for_old_pandas():
if not hasattr(pd.api, "interchange"):
pd.api.interchange = mock.MagicMock()
# to make the following import work: `import pandas.api.interchange`
with mock.patch.dict("sys.modules", {"pandas.api.interchange": pd.api.interchange}):
yield
else:
yield


def test_numpy():
fig = px.scatter(x=[1, 2, 3], y=[2, 3, 4], color=[1, 3, 9])
Expand Down Expand Up @@ -234,7 +246,7 @@ def test_build_df_with_index():
assert_frame_equal(tips.reset_index()[out["data_frame"].columns], out["data_frame"])


def test_build_df_using_interchange_protocol_mock():
def test_build_df_using_interchange_protocol_mock(add_interchange_module_for_old_pandas):
class CustomDataFrame:
def __dataframe__(self):
pass
Expand Down

0 comments on commit 9b2154e

Please sign in to comment.