Skip to content

Commit 405aa03

Browse files
jbrockmendelnoatamir
authored andcommitted
TST: catch some test warnings (pandas-dev#48165)
1 parent d235e7a commit 405aa03

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

pandas/tests/groupby/test_function.py

+1
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ def test_corrwith_with_1_axis():
15901590
tm.assert_series_equal(result, expected)
15911591

15921592

1593+
@pytest.mark.filterwarnings("ignore:The 'mad' method.*:FutureWarning")
15931594
def test_multiindex_group_all_columns_when_empty(groupby_func):
15941595
# GH 32464
15951596
df = DataFrame({"a": [], "b": [], "c": []}).set_index(["a", "b", "c"])

pandas/tests/groupby/test_groupby.py

+1
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,7 @@ def test_groupby_duplicate_index():
23492349
tm.assert_series_equal(result, expected)
23502350

23512351

2352+
@pytest.mark.filterwarnings("ignore:.*is deprecated.*:FutureWarning")
23522353
def test_group_on_empty_multiindex(transformation_func, request):
23532354
# GH 47787
23542355
# With one row, those are transforms so the schema should be the same

pandas/tests/groupby/test_groupby_dropna.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,15 @@ def test_no_sort_keep_na(values, dtype, test_series):
439439
gb = df.groupby("key", dropna=False, sort=False)
440440
if test_series:
441441
gb = gb["a"]
442-
result = gb.sum()
443-
expected = pd.DataFrame({"a": [5, 2, 3]}, index=key[:-1].rename("key"))
442+
443+
warn = None
444+
if isinstance(values, pd.arrays.SparseArray):
445+
warn = FutureWarning
446+
msg = "passing a SparseArray to pd.Index will store that array directly"
447+
with tm.assert_produces_warning(warn, match=msg):
448+
result = gb.sum()
449+
expected = pd.DataFrame({"a": [5, 2, 3]}, index=key[:-1].rename("key"))
450+
444451
if test_series:
445452
expected = expected["a"]
446453
if expected.index.is_categorical():

pandas/tests/indexes/multi/test_setops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,5 @@ def test_intersection_lexsort_depth(levels1, levels2, codes1, codes2, names):
572572
mi2 = MultiIndex(levels=levels2, codes=codes2, names=names)
573573
mi_int = mi1.intersection(mi2)
574574

575-
assert mi_int.lexsort_depth == 0
575+
with tm.assert_produces_warning(FutureWarning, match="MultiIndex.lexsort_depth"):
576+
assert mi_int.lexsort_depth == 0

pandas/tests/io/test_stata.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,8 @@ def test_big_dates(self, datapath):
817817
# {c : c[-2:] for c in columns}
818818
with tm.ensure_clean() as path:
819819
expected.index.name = "index"
820-
expected.to_stata(path, date_conversion)
820+
with tm.assert_produces_warning(FutureWarning, match="keyword-only"):
821+
expected.to_stata(path, date_conversion)
821822
written_and_read_again = self.read_dta(path)
822823
tm.assert_frame_equal(
823824
written_and_read_again.set_index("index"),

0 commit comments

Comments
 (0)