From 613912404411ce28875de13f6a4f942c077f1f75 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 13 Oct 2022 17:56:21 +0200 Subject: [PATCH 1/2] CI: Fix DeprecationWarning of numpy dev --- pandas/tests/series/test_constructors.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index a33912178bfd6..9aeef9af8b5e2 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -14,6 +14,7 @@ iNaT, lib, ) +from pandas.compat import is_numpy_dev import pandas.util._test_decorators as td from pandas.core.dtypes.common import ( @@ -735,13 +736,14 @@ def test_constructor_cast(self): def test_constructor_signed_int_overflow_deprecation(self): # GH#41734 disallow silent overflow msg = "Values are too large to be losslessly cast" - with tm.assert_produces_warning(FutureWarning, match=msg): + numpy_warning = DeprecationWarning if is_numpy_dev else None + with tm.assert_produces_warning((FutureWarning, numpy_warning), match=msg): ser = Series([1, 200, 923442], dtype="int8") expected = Series([1, -56, 50], dtype="int8") tm.assert_series_equal(ser, expected) - with tm.assert_produces_warning(FutureWarning, match=msg): + with tm.assert_produces_warning((FutureWarning, numpy_warning), match=msg): ser = Series([1, 200, 923442], dtype="uint8") expected = Series([1, 200, 50], dtype="uint8") From 674f830da0245924cf0362a82ef2e7a5376494fc Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 13 Oct 2022 19:29:20 +0200 Subject: [PATCH 2/2] CI: Fix DeprecationWarning of numpy dev --- pandas/tests/series/test_constructors.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 9aeef9af8b5e2..7bb01ad800aef 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -737,13 +737,17 @@ def test_constructor_signed_int_overflow_deprecation(self): # GH#41734 disallow silent overflow msg = "Values are too large to be losslessly cast" numpy_warning = DeprecationWarning if is_numpy_dev else None - with tm.assert_produces_warning((FutureWarning, numpy_warning), match=msg): + with tm.assert_produces_warning( + (FutureWarning, numpy_warning), match=msg, check_stacklevel=False + ): ser = Series([1, 200, 923442], dtype="int8") expected = Series([1, -56, 50], dtype="int8") tm.assert_series_equal(ser, expected) - with tm.assert_produces_warning((FutureWarning, numpy_warning), match=msg): + with tm.assert_produces_warning( + (FutureWarning, numpy_warning), match=msg, check_stacklevel=False + ): ser = Series([1, 200, 923442], dtype="uint8") expected = Series([1, 200, 50], dtype="uint8")