Skip to content

Commit d2e8cb4

Browse files
chore: fix pytest crash on pandas 3.0 due to missing SettingWithCopyWarning (#2314)
Moved `ignore::pandas.errors.SettingWithCopyWarning` from `pytest.ini` to `conftest.py` with a check for its existence. This fixes `AttributeError: module 'pandas.errors' has no attribute 'SettingWithCopyWarning'` when running tests against pandas 3.0. --- *PR created automatically by Jules for task [1336882389279070030](https://jules.google.com/task/1336882389279070030) started by @tswast* Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent dbb0339 commit d2e8cb4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414

1515
from __future__ import annotations
1616

17+
import warnings
18+
1719
import numpy as np
1820
import pandas as pd
1921
import pyarrow as pa
2022
import pytest
2123

2224
import bigframes._config
2325

26+
# Make sure SettingWithCopyWarning is ignored if it exists.
27+
# It was removed in pandas 3.0.
28+
if hasattr(pd.errors, "SettingWithCopyWarning"):
29+
warnings.simplefilter("ignore", pd.errors.SettingWithCopyWarning)
30+
2431

2532
@pytest.fixture(scope="session")
2633
def polars_session_or_bpd():

pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[pytest]
22
doctest_optionflags = NORMALIZE_WHITESPACE
3-
filterwarnings =
4-
ignore::pandas.errors.SettingWithCopyWarning
53
addopts = "--import-mode=importlib"

0 commit comments

Comments
 (0)