Skip to content

TST: catch some test warnings #48165

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

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ def test_corrwith_with_1_axis():
tm.assert_series_equal(result, expected)


@pytest.mark.filterwarnings("ignore:The 'mad' method.*:FutureWarning")
def test_multiindex_group_all_columns_when_empty(groupby_func):
# GH 32464
df = DataFrame({"a": [], "b": [], "c": []}).set_index(["a", "b", "c"])
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ def test_groupby_duplicate_index():
tm.assert_series_equal(result, expected)


@pytest.mark.filterwarnings("ignore:.*is deprecated.*:FutureWarning")
def test_group_on_empty_multiindex(transformation_func, request):
# GH 47787
# With one row, those are transforms so the schema should be the same
Expand Down
11 changes: 9 additions & 2 deletions pandas/tests/groupby/test_groupby_dropna.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,15 @@ def test_no_sort_keep_na(values, dtype, test_series):
gb = df.groupby("key", dropna=False, sort=False)
if test_series:
gb = gb["a"]
result = gb.sum()
expected = pd.DataFrame({"a": [5, 2, 3]}, index=key[:-1].rename("key"))

warn = None
if isinstance(values, pd.arrays.SparseArray):
warn = FutureWarning
msg = "passing a SparseArray to pd.Index will store that array directly"
with tm.assert_produces_warning(warn, match=msg):
result = gb.sum()
expected = pd.DataFrame({"a": [5, 2, 3]}, index=key[:-1].rename("key"))

if test_series:
expected = expected["a"]
if expected.index.is_categorical():
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/indexes/multi/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,5 @@ def test_intersection_lexsort_depth(levels1, levels2, codes1, codes2, names):
mi2 = MultiIndex(levels=levels2, codes=codes2, names=names)
mi_int = mi1.intersection(mi2)

assert mi_int.lexsort_depth == 0
with tm.assert_produces_warning(FutureWarning, match="MultiIndex.lexsort_depth"):
assert mi_int.lexsort_depth == 0
3 changes: 2 additions & 1 deletion pandas/tests/io/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ def test_big_dates(self, datapath):
# {c : c[-2:] for c in columns}
with tm.ensure_clean() as path:
expected.index.name = "index"
expected.to_stata(path, date_conversion)
with tm.assert_produces_warning(FutureWarning, match="keyword-only"):
expected.to_stata(path, date_conversion)
written_and_read_again = self.read_dta(path)
tm.assert_frame_equal(
written_and_read_again.set_index("index"),
Expand Down