From 2d5bcaaeb5e6938274e5256908b5cdcec5e45cd3 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 19 Nov 2022 01:04:35 +0530 Subject: [PATCH 01/12] for issue 429 --- tests/test_errors.py | 24 ++++++++++++------------ tests/test_frame.py | 2 +- tests/test_indexes.py | 2 +- tests/test_pandas.py | 12 ++++++------ tests/test_scalars.py | 4 ++-- tests/test_series.py | 18 +++++++++--------- tests/test_utility.py | 2 +- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index f507302a6..d07e26f93 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -15,12 +15,12 @@ class Foo: def test_accessor_registration_warning() -> None: - with pytest.warns(errors.AccessorRegistrationWarning): + with python_warns_bounded(errors.AccessorRegistrationWarning): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with pytest.warns(errors.DtypeWarning): + with python_warns_bounded(errors.DtypeWarning): warnings.warn("", errors.DtypeWarning) @@ -80,12 +80,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with pytest.warns(errors.ParserWarning): + with python_warns_bounded(errors.ParserWarning): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with pytest.warns(errors.PerformanceWarning): + with python_warns_bounded(errors.PerformanceWarning): warnings.warn("", errors.PerformanceWarning) @@ -115,7 +115,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with pytest.warns(errors.SettingWithCopyWarning): + with python_warns_bounded(errors.SettingWithCopyWarning): warnings.warn("", errors.SettingWithCopyWarning) @@ -146,7 +146,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with pytest.warns(errors.CSSWarning): + with python_warns_bounded(errors.CSSWarning): warnings.warn("", errors.CSSWarning) @@ -161,12 +161,12 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with pytest.warns(errors.IncompatibilityWarning): + with python_warns_bounded(errors.IncompatibilityWarning): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with pytest.warns(errors.AttributeConflictWarning): + with python_warns_bounded(errors.AttributeConflictWarning): warnings.warn("", errors.AttributeConflictWarning) @@ -176,20 +176,20 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with pytest.warns(errors.PossiblePrecisionLoss): + with python_warns_bounded(errors.PossiblePrecisionLoss): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with pytest.warns(errors.ValueLabelTypeMismatch): + with python_warns_bounded(errors.ValueLabelTypeMismatch): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with pytest.warns(errors.InvalidColumnName): + with python_warns_bounded(errors.InvalidColumnName): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with pytest.warns(errors.CategoricalConversionWarning): + with python_warns_bounded(errors.CategoricalConversionWarning): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_frame.py b/tests/test_frame.py index b7108d1a5..19736de36 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -1299,7 +1299,7 @@ def test_groupby_series_methods() -> None: gb.min().loc[2] gb.nlargest().loc[2] gb.nsmallest().loc[2] - gb.nth(0).loc[2] + gb.nth(0).loc[1] def test_indexslice_setitem(): diff --git a/tests/test_indexes.py b/tests/test_indexes.py index 18e8e0203..cb7c2f8d8 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -166,7 +166,7 @@ def test_index_relops() -> None: def test_range_index_union(): - with pytest.warns(FutureWarning, match="pandas.Int64Index"): + with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index"): check( assert_type( pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 456f94947..4d43ebd69 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -752,14 +752,14 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with pytest.warns(FutureWarning, match="pandas.Float64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.Float64Index is deprecated"): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with pytest.warns(FutureWarning, match="pandas.Int64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.Int64Index is deprecated"): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with pytest.warns(FutureWarning, match="pandas.UInt64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.UInt64Index is deprecated"): ui = pd.UInt64Index([0, 1, 2, 3, 5]) tdi = pd.timedelta_range("1 day", "10 days", periods=10) mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]]) @@ -1419,7 +1419,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with pytest.warns(FutureWarning): + with python_warns_bounded(FutureWarning): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1674,7 +1674,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest.warns(np.VisibleDeprecationWarning): + with python_warns_bounded(np.VisibleDeprecationWarning): check( assert_type( pd.pivot_table( @@ -1688,7 +1688,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest.warns(np.VisibleDeprecationWarning): + with python_warns_bounded(np.VisibleDeprecationWarning): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 5c788909d..cfbcc6bb2 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None: def test_timedelta_mul_div() -> None: td = pd.Timedelta("1 day") - with pytest.warns(FutureWarning): + with python_warns_bounded(FutureWarning): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None: def test_timedelta_mod_abs_unary() -> None: td = pd.Timedelta("1 day") - with pytest.warns(FutureWarning): + with python_warns_bounded(FutureWarning): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) diff --git a/tests/test_series.py b/tests/test_series.py index f37631d6a..c81558cc2 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -260,15 +260,15 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with pytest.warns(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): s.rank() - with pytest.warns(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): s.rank(axis=0, na_option="bottom") - with pytest.warns(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): s.rank(method="min", pct=True) - with pytest.warns(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): s.rank(method="dense", ascending=True) - with pytest.warns(FutureWarning, match="Calling Series.rank with numeric_only"): + with python_warns_bounded(FutureWarning, match="Calling Series.rank with numeric_only"): s.rank(method="first", numeric_only=True) s2 = pd.Series([1, 1, 2, 5, 6, np.nan]) s2.rank(method="first", numeric_only=True) @@ -643,17 +643,17 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with pytest.warns(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): s.describe() - with pytest.warns(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): s.describe(percentiles=[0.5], include="all") - with pytest.warns(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): s.describe(exclude=np.number) if PD_LTE_15: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with pytest.warns(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index 9a27f822c..70b331d17 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -6,7 +6,7 @@ def test_show_version(): - with pytest.warns(UserWarning, match="Setuptools is replacing distutils"): + with python_warns_bounded(UserWarning, match="Setuptools is replacing distutils"): check(assert_type(pd.show_versions(True), None), type(None)) check(assert_type(pd.show_versions(False), None), type(None)) From 0779883e4e286349cfd9eb569b8c80b283768f9d Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 19 Nov 2022 14:09:12 +0530 Subject: [PATCH 02/12] update --- tests/test_errors.py | 24 ++++++++++++------------ tests/test_indexes.py | 2 +- tests/test_pandas.py | 12 ++++++------ tests/test_scalars.py | 4 ++-- tests/test_series.py | 18 +++++++++--------- tests/test_utility.py | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index d07e26f93..dc6b0f5be 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -15,12 +15,12 @@ class Foo: def test_accessor_registration_warning() -> None: - with python_warns_bounded(errors.AccessorRegistrationWarning): + with python_warns_bounded(errors.AccessorRegistrationWarning, upper="1.5.99"): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with python_warns_bounded(errors.DtypeWarning): + with python_warns_bounded(errors.DtypeWarning, upper="1.5.99"): warnings.warn("", errors.DtypeWarning) @@ -80,12 +80,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with python_warns_bounded(errors.ParserWarning): + with python_warns_bounded(errors.ParserWarning, upper="1.5.99"): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with python_warns_bounded(errors.PerformanceWarning): + with python_warns_bounded(errors.PerformanceWarning, upper="1.5.99"): warnings.warn("", errors.PerformanceWarning) @@ -115,7 +115,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with python_warns_bounded(errors.SettingWithCopyWarning): + with python_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99"): warnings.warn("", errors.SettingWithCopyWarning) @@ -146,7 +146,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with python_warns_bounded(errors.CSSWarning): + with python_warns_bounded(errors.CSSWarning, upper="1.5.99"): warnings.warn("", errors.CSSWarning) @@ -161,12 +161,12 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with python_warns_bounded(errors.IncompatibilityWarning): + with python_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99"): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with python_warns_bounded(errors.AttributeConflictWarning): + with python_warns_bounded(errors.AttributeConflictWarning, upper="1.5.99"): warnings.warn("", errors.AttributeConflictWarning) @@ -176,20 +176,20 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with python_warns_bounded(errors.PossiblePrecisionLoss): + with python_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99"): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with python_warns_bounded(errors.ValueLabelTypeMismatch): + with python_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99"): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with python_warns_bounded(errors.InvalidColumnName): + with python_warns_bounded(errors.InvalidColumnName, upper="1.5.99"): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with python_warns_bounded(errors.CategoricalConversionWarning): + with python_warns_bounded(errors.CategoricalConversionWarning, upper="1.5.99"): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_indexes.py b/tests/test_indexes.py index cb7c2f8d8..a7c3b1bbd 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -166,7 +166,7 @@ def test_index_relops() -> None: def test_range_index_union(): - with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index"): + with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index", upper="1.5.99"): check( assert_type( pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 4d43ebd69..c9af5cbd0 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -752,14 +752,14 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with python_warns_bounded(FutureWarning, match="pandas.Float64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99"): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with python_warns_bounded(FutureWarning, match="pandas.Int64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99"): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with python_warns_bounded(FutureWarning, match="pandas.UInt64Index is deprecated"): + with python_warns_bounded(FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99"): ui = pd.UInt64Index([0, 1, 2, 3, 5]) tdi = pd.timedelta_range("1 day", "10 days", periods=10) mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]]) @@ -1419,7 +1419,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with python_warns_bounded(FutureWarning): + with python_warns_bounded(FutureWarning, upper="1.5.99"): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1674,7 +1674,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with python_warns_bounded(np.VisibleDeprecationWarning): + with python_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( @@ -1688,7 +1688,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with python_warns_bounded(np.VisibleDeprecationWarning): + with python_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index cfbcc6bb2..ed08bd5d2 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None: def test_timedelta_mul_div() -> None: td = pd.Timedelta("1 day") - with python_warns_bounded(FutureWarning): + with python_warns_bounded(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None: def test_timedelta_mod_abs_unary() -> None: td = pd.Timedelta("1 day") - with python_warns_bounded(FutureWarning): + with python_warns_bounded(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) diff --git a/tests/test_series.py b/tests/test_series.py index c81558cc2..843671c31 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -260,15 +260,15 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): s.rank() - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): s.rank(axis=0, na_option="bottom") - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): s.rank(method="min", pct=True) - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns"): + with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): s.rank(method="dense", ascending=True) - with python_warns_bounded(FutureWarning, match="Calling Series.rank with numeric_only"): + with python_warns_bounded(FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99"): s.rank(method="first", numeric_only=True) s2 = pd.Series([1, 1, 2, 5, 6, np.nan]) s2.rank(method="first", numeric_only=True) @@ -643,17 +643,17 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): s.describe() - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): s.describe(percentiles=[0.5], include="all") - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): s.describe(exclude=np.number) if PD_LTE_15: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed"): + with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index 70b331d17..6dac20a7b 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -6,7 +6,7 @@ def test_show_version(): - with python_warns_bounded(UserWarning, match="Setuptools is replacing distutils"): + with python_warns_bounded(UserWarning, match="Setuptools is replacing distutils", upper="1.5.99"): check(assert_type(pd.show_versions(True), None), type(None)) check(assert_type(pd.show_versions(False), None), type(None)) From 3be0a03dc638819a6f676a1b35465d71066660e2 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 19 Nov 2022 14:12:54 +0530 Subject: [PATCH 03/12] update --- tests/test_pandas.py | 12 +++++++++--- tests/test_series.py | 36 +++++++++++++++++++++++++++--------- tests/test_utility.py | 4 +++- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/tests/test_pandas.py b/tests/test_pandas.py index c9af5cbd0..8b15c7fbe 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -752,14 +752,20 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with python_warns_bounded(FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99" + ): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with python_warns_bounded(FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99" + ): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with python_warns_bounded(FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99" + ): ui = pd.UInt64Index([0, 1, 2, 3, 5]) tdi = pd.timedelta_range("1 day", "10 days", periods=10) mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]]) diff --git a/tests/test_series.py b/tests/test_series.py index 843671c31..0c8411579 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -260,15 +260,25 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" + ): s.rank() - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" + ): s.rank(axis=0, na_option="bottom") - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" + ): s.rank(method="min", pct=True) - with python_warns_bounded(FutureWarning, match="Dropping of nuisance columns", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" + ): s.rank(method="dense", ascending=True) - with python_warns_bounded(FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99"): + with python_warns_bounded( + FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99" + ): s.rank(method="first", numeric_only=True) s2 = pd.Series([1, 1, 2, 5, 6, np.nan]) s2.rank(method="first", numeric_only=True) @@ -643,17 +653,25 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): + with python_warns_bounded( + DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" + ): s.describe() - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): + with python_warns_bounded( + DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" + ): s.describe(percentiles=[0.5], include="all") - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): + with python_warns_bounded( + DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" + ): s.describe(exclude=np.number) if PD_LTE_15: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with python_warns_bounded(DeprecationWarning, match="elementwise comparison failed", upper="1.5.99"): + with python_warns_bounded( + DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" + ): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index 6dac20a7b..a33568de2 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -6,7 +6,9 @@ def test_show_version(): - with python_warns_bounded(UserWarning, match="Setuptools is replacing distutils", upper="1.5.99"): + with python_warns_bounded( + UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" + ): check(assert_type(pd.show_versions(True), None), type(None)) check(assert_type(pd.show_versions(False), None), type(None)) From 1b9d0b467c39394d08b7bb3edb617d272fba0ea9 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sun, 20 Nov 2022 11:49:11 +0530 Subject: [PATCH 04/12] update --- tests/test_errors.py | 24 ++++++++++++------------ tests/test_pandas.py | 12 ++++++------ tests/test_scalars.py | 4 ++-- tests/test_series.py | 18 +++++++++--------- tests/test_utility.py | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index dc6b0f5be..2367194d3 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -15,12 +15,12 @@ class Foo: def test_accessor_registration_warning() -> None: - with python_warns_bounded(errors.AccessorRegistrationWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.AccessorRegistrationWarning, upper="1.5.99"): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with python_warns_bounded(errors.DtypeWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.DtypeWarning, upper="1.5.99"): warnings.warn("", errors.DtypeWarning) @@ -80,12 +80,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with python_warns_bounded(errors.ParserWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.ParserWarning, upper="1.5.99"): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with python_warns_bounded(errors.PerformanceWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.PerformanceWarning, upper="1.5.99"): warnings.warn("", errors.PerformanceWarning) @@ -115,7 +115,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with python_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99"): warnings.warn("", errors.SettingWithCopyWarning) @@ -146,7 +146,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with python_warns_bounded(errors.CSSWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.CSSWarning, upper="1.5.99"): warnings.warn("", errors.CSSWarning) @@ -161,12 +161,12 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with python_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99"): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with python_warns_bounded(errors.AttributeConflictWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.AttributeConflictWarning, upper="1.5.99"): warnings.warn("", errors.AttributeConflictWarning) @@ -176,20 +176,20 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with python_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99"): + with pytest_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99"): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with python_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99"): + with pytest_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99"): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with python_warns_bounded(errors.InvalidColumnName, upper="1.5.99"): + with pytest_warns_bounded(errors.InvalidColumnName, upper="1.5.99"): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with python_warns_bounded(errors.CategoricalConversionWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.CategoricalConversionWarning, upper="1.5.99"): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 8b15c7fbe..b2bcfb7f2 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -752,18 +752,18 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99" ): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99" ): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99" ): ui = pd.UInt64Index([0, 1, 2, 3, 5]) @@ -1425,7 +1425,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with python_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99"): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1680,7 +1680,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with python_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( @@ -1694,7 +1694,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with python_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index ed08bd5d2..bd720029d 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None: def test_timedelta_mul_div() -> None: td = pd.Timedelta("1 day") - with python_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None: def test_timedelta_mod_abs_unary() -> None: td = pd.Timedelta("1 day") - with python_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) diff --git a/tests/test_series.py b/tests/test_series.py index 0c8411579..1bf49de55 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -260,23 +260,23 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank() - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(axis=0, na_option="bottom") - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="min", pct=True) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="dense", ascending=True) - with python_warns_bounded( + with pytest_warns_bounded( FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99" ): s.rank(method="first", numeric_only=True) @@ -653,15 +653,15 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with python_warns_bounded( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe() - with python_warns_bounded( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(percentiles=[0.5], include="all") - with python_warns_bounded( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(exclude=np.number) @@ -669,7 +669,7 @@ def test_types_describe() -> None: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with python_warns_bounded( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index a33568de2..207502a33 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -6,7 +6,7 @@ def test_show_version(): - with python_warns_bounded( + with pytest_warns_bounded( UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" ): check(assert_type(pd.show_versions(True), None), type(None)) From 25e1bddc32f8568adebf7c5fe03e9fd9a3aabee5 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sun, 20 Nov 2022 12:15:40 +0530 Subject: [PATCH 05/12] update --- tests/test_errors.py | 24 ++++++++++++------------ tests/test_indexes.py | 2 +- tests/test_pandas.py | 12 ++++++------ tests/test_scalars.py | 4 ++-- tests/test_series.py | 18 +++++++++--------- tests/test_utility.py | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 2367194d3..32fcf046a 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -15,12 +15,12 @@ class Foo: def test_accessor_registration_warning() -> None: - with pytest_warns_bounded(errors.AccessorRegistrationWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.AccessorRegistrationWarning, upper="1.5.99"): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with pytest_warns_bounded(errors.DtypeWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.DtypeWarning, upper="1.5.99"): warnings.warn("", errors.DtypeWarning) @@ -80,12 +80,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with pytest_warns_bounded(errors.ParserWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.ParserWarning, upper="1.5.99"): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with pytest_warns_bounded(errors.PerformanceWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.PerformanceWarning, upper="1.5.99"): warnings.warn("", errors.PerformanceWarning) @@ -115,7 +115,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with pytest_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.SettingWithCopyWarning, upper="1.5.99"): warnings.warn("", errors.SettingWithCopyWarning) @@ -146,7 +146,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with pytest_warns_bounded(errors.CSSWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.CSSWarning, upper="1.5.99"): warnings.warn("", errors.CSSWarning) @@ -161,12 +161,12 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with pytest_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.IncompatibilityWarning, upper="1.5.99"): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with pytest_warns_bounded(errors.AttributeConflictWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.AttributeConflictWarning, upper="1.5.99"): warnings.warn("", errors.AttributeConflictWarning) @@ -176,20 +176,20 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with pytest_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99"): + with pytest_warns_bounds(errors.PossiblePrecisionLoss, upper="1.5.99"): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with pytest_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99"): + with pytest_warns_bounds(errors.ValueLabelTypeMismatch, upper="1.5.99"): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with pytest_warns_bounded(errors.InvalidColumnName, upper="1.5.99"): + with pytest_warns_bounds(errors.InvalidColumnName, upper="1.5.99"): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with pytest_warns_bounded(errors.CategoricalConversionWarning, upper="1.5.99"): + with pytest_warns_bounds(errors.CategoricalConversionWarning, upper="1.5.99"): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_indexes.py b/tests/test_indexes.py index a7c3b1bbd..f1f916201 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -166,7 +166,7 @@ def test_index_relops() -> None: def test_range_index_union(): - with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index", upper="1.5.99"): + with pytest_warns_bounds(FutureWarning, match="pandas.Int64Index", upper="1.5.99"): check( assert_type( pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), diff --git a/tests/test_pandas.py b/tests/test_pandas.py index b2bcfb7f2..7545ca3bd 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -752,18 +752,18 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99" ): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99" ): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99" ): ui = pd.UInt64Index([0, 1, 2, 3, 5]) @@ -1425,7 +1425,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounds(FutureWarning, upper="1.5.99"): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1680,7 +1680,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounds(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( @@ -1694,7 +1694,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounds(np.VisibleDeprecationWarning, upper="1.5.99"): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index bd720029d..237c67d5b 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None: def test_timedelta_mul_div() -> None: td = pd.Timedelta("1 day") - with pytest_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounds(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None: def test_timedelta_mod_abs_unary() -> None: td = pd.Timedelta("1 day") - with pytest_warns_bounded(FutureWarning, upper="1.5.99"): + with pytest_warns_bounds(FutureWarning, upper="1.5.99"): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) diff --git a/tests/test_series.py b/tests/test_series.py index 1bf49de55..37ca0de85 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -260,23 +260,23 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank() - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(axis=0, na_option="bottom") - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="min", pct=True) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="dense", ascending=True) - with pytest_warns_bounded( + with pytest_warns_bounds( FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99" ): s.rank(method="first", numeric_only=True) @@ -653,15 +653,15 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with pytest_warns_bounded( + with pytest_warns_bounds( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe() - with pytest_warns_bounded( + with pytest_warns_bounds( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(percentiles=[0.5], include="all") - with pytest_warns_bounded( + with pytest_warns_bounds( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(exclude=np.number) @@ -669,7 +669,7 @@ def test_types_describe() -> None: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with pytest_warns_bounded( + with pytest_warns_bounds( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index 207502a33..f16e1aa7f 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -6,7 +6,7 @@ def test_show_version(): - with pytest_warns_bounded( + with pytest_warns_bounds( UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" ): check(assert_type(pd.show_versions(True), None), type(None)) From 2301336a54416eae2ced92afae8015cd8b12c293 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Mon, 21 Nov 2022 10:05:25 +0530 Subject: [PATCH 06/12] Update test_indexes.py --- tests/test_indexes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_indexes.py b/tests/test_indexes.py index f1f916201..db03402f4 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -7,7 +7,7 @@ from numpy import typing as npt import pandas as pd from pandas.core.indexes.numeric import NumericIndex -import pytest +import pytest_warns_bounds from typing_extensions import assert_type from tests import check From 7f74bfc2b77629a7fe104c126ace933d03ca0d2b Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Mon, 21 Nov 2022 10:42:16 +0530 Subject: [PATCH 07/12] update --- tests/test_errors.py | 2 +- tests/test_pandas.py | 2 +- tests/test_scalars.py | 2 +- tests/test_series.py | 2 +- tests/test_utility.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 32fcf046a..48adebd66 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,7 +1,7 @@ import warnings from pandas import errors -import pytest +import pytest_warns_bounds from tests import WINDOWS diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 7545ca3bd..6eb0a1a9f 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -13,7 +13,7 @@ import pandas as pd from pandas import Grouper from pandas.api.extensions import ExtensionArray -import pytest +import pytest_warns_bounds from typing_extensions import assert_type from pandas._libs.missing import NAType diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 237c67d5b..318771f20 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -13,7 +13,7 @@ import numpy as np from numpy import typing as npt import pandas as pd -import pytest +import pytest_warns_bounds import pytz from typing_extensions import ( TypeAlias, diff --git a/tests/test_series.py b/tests/test_series.py index 37ca0de85..3f1f3d285 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -23,7 +23,7 @@ ExtensionDtype, ) from pandas.core.window import ExponentialMovingWindow -import pytest +import pytest_warns_bounds from typing_extensions import assert_type import xarray as xr diff --git a/tests/test_utility.py b/tests/test_utility.py index f16e1aa7f..4e50f60b8 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -1,5 +1,5 @@ import pandas as pd -import pytest +import pytest_warns_bounds from typing_extensions import assert_type from tests import check From 4bf990f1793d1e26cbdd250d0b56e0d6c7a58bd6 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Mon, 21 Nov 2022 10:45:54 +0530 Subject: [PATCH 08/12] update --- tests/test_errors.py | 1 + tests/test_indexes.py | 1 + tests/test_pandas.py | 1 + tests/test_scalars.py | 1 + tests/test_series.py | 1 + 5 files changed, 5 insertions(+) diff --git a/tests/test_errors.py b/tests/test_errors.py index 48adebd66..a255d314b 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -2,6 +2,7 @@ from pandas import errors import pytest_warns_bounds +import pytest from tests import WINDOWS diff --git a/tests/test_indexes.py b/tests/test_indexes.py index db03402f4..c46bdf415 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -8,6 +8,7 @@ import pandas as pd from pandas.core.indexes.numeric import NumericIndex import pytest_warns_bounds +import pytest from typing_extensions import assert_type from tests import check diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 6eb0a1a9f..1d73b3951 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -14,6 +14,7 @@ from pandas import Grouper from pandas.api.extensions import ExtensionArray import pytest_warns_bounds +import pytest from typing_extensions import assert_type from pandas._libs.missing import NAType diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 318771f20..f3b580e3c 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -14,6 +14,7 @@ from numpy import typing as npt import pandas as pd import pytest_warns_bounds +import pytest import pytz from typing_extensions import ( TypeAlias, diff --git a/tests/test_series.py b/tests/test_series.py index 3f1f3d285..4d1134a22 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -24,6 +24,7 @@ ) from pandas.core.window import ExponentialMovingWindow import pytest_warns_bounds +import pytest from typing_extensions import assert_type import xarray as xr From d72a19976c17c4e2c1f12bbb489bc7e6e93bb97e Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Mon, 21 Nov 2022 10:48:56 +0530 Subject: [PATCH 09/12] update --- tests/test_errors.py | 2 +- tests/test_indexes.py | 1 - tests/test_pandas.py | 2 +- tests/test_scalars.py | 1 - tests/test_series.py | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index a255d314b..07e6bca3a 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,8 +1,8 @@ import warnings from pandas import errors -import pytest_warns_bounds import pytest +import pytest_warns_bounds from tests import WINDOWS diff --git a/tests/test_indexes.py b/tests/test_indexes.py index c46bdf415..db03402f4 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -8,7 +8,6 @@ import pandas as pd from pandas.core.indexes.numeric import NumericIndex import pytest_warns_bounds -import pytest from typing_extensions import assert_type from tests import check diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 1d73b3951..b8545c8e8 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -13,8 +13,8 @@ import pandas as pd from pandas import Grouper from pandas.api.extensions import ExtensionArray -import pytest_warns_bounds import pytest +import pytest_warns_bounds from typing_extensions import assert_type from pandas._libs.missing import NAType diff --git a/tests/test_scalars.py b/tests/test_scalars.py index f3b580e3c..318771f20 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -14,7 +14,6 @@ from numpy import typing as npt import pandas as pd import pytest_warns_bounds -import pytest import pytz from typing_extensions import ( TypeAlias, diff --git a/tests/test_series.py b/tests/test_series.py index 4d1134a22..db8f1fe85 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -23,8 +23,8 @@ ExtensionDtype, ) from pandas.core.window import ExponentialMovingWindow -import pytest_warns_bounds import pytest +import pytest_warns_bounds from typing_extensions import assert_type import xarray as xr From 6f01e8e889a99d9a5209266cd19d80692db7b292 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Tue, 22 Nov 2022 16:31:48 +0530 Subject: [PATCH 10/12] update --- tests/test_errors.py | 36 ++++++++++++++++++++++-------------- tests/test_indexes.py | 8 +++++--- tests/test_pandas.py | 14 +++++++------- tests/test_scalars.py | 6 +++--- tests/test_series.py | 20 ++++++++++---------- tests/test_utility.py | 8 +++++--- 6 files changed, 52 insertions(+), 40 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 07e6bca3a..a2d3cefa2 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -2,9 +2,11 @@ from pandas import errors import pytest -import pytest_warns_bounds -from tests import WINDOWS +from tests import ( + WINDOWS, + pytest_warns_bounded, +) def test_abstract_method_error() -> None: @@ -16,12 +18,14 @@ class Foo: def test_accessor_registration_warning() -> None: - with pytest_warns_bounds(errors.AccessorRegistrationWarning, upper="1.5.99"): + with pytest_warns_bounded( + errors.AccessorRegistrationWarning, upper="1.5.99", match="" + ): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with pytest_warns_bounds(errors.DtypeWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.DtypeWarning, upper="1.5.99", match=""): warnings.warn("", errors.DtypeWarning) @@ -81,12 +85,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with pytest_warns_bounds(errors.ParserWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.ParserWarning, upper="1.5.99", match=""): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with pytest_warns_bounds(errors.PerformanceWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.PerformanceWarning, upper="1.5.99", match=""): warnings.warn("", errors.PerformanceWarning) @@ -116,7 +120,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with pytest_warns_bounds(errors.SettingWithCopyWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99", match=""): warnings.warn("", errors.SettingWithCopyWarning) @@ -147,7 +151,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with pytest_warns_bounds(errors.CSSWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.CSSWarning, upper="1.5.99", match=""): warnings.warn("", errors.CSSWarning) @@ -162,12 +166,14 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with pytest_warns_bounds(errors.IncompatibilityWarning, upper="1.5.99"): + with pytest_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99", match=""): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with pytest_warns_bounds(errors.AttributeConflictWarning, upper="1.5.99"): + with pytest_warns_bounded( + errors.AttributeConflictWarning, upper="1.5.99", match="" + ): warnings.warn("", errors.AttributeConflictWarning) @@ -177,20 +183,22 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with pytest_warns_bounds(errors.PossiblePrecisionLoss, upper="1.5.99"): + with pytest_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99", match=""): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with pytest_warns_bounds(errors.ValueLabelTypeMismatch, upper="1.5.99"): + with pytest_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99", match=""): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with pytest_warns_bounds(errors.InvalidColumnName, upper="1.5.99"): + with pytest_warns_bounded(errors.InvalidColumnName, upper="1.5.99", match=""): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with pytest_warns_bounds(errors.CategoricalConversionWarning, upper="1.5.99"): + with pytest_warns_bounded( + errors.CategoricalConversionWarning, upper="1.5.99", match="" + ): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_indexes.py b/tests/test_indexes.py index db03402f4..1eab40612 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -7,10 +7,12 @@ from numpy import typing as npt import pandas as pd from pandas.core.indexes.numeric import NumericIndex -import pytest_warns_bounds from typing_extensions import assert_type -from tests import check +from tests import ( + check, + pytest_warns_bounded, +) def test_index_unique() -> None: @@ -166,7 +168,7 @@ def test_index_relops() -> None: def test_range_index_union(): - with pytest_warns_bounds(FutureWarning, match="pandas.Int64Index", upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, match="pandas.Int64Index", upper="1.5.99"): check( assert_type( pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)), diff --git a/tests/test_pandas.py b/tests/test_pandas.py index b8545c8e8..c49b7f048 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -14,7 +14,6 @@ from pandas import Grouper from pandas.api.extensions import ExtensionArray import pytest -import pytest_warns_bounds from typing_extensions import assert_type from pandas._libs.missing import NAType @@ -24,6 +23,7 @@ from tests import ( TYPE_CHECKING_INVALID_USAGE, check, + pytest_warns_bounded, ) @@ -753,18 +753,18 @@ def test_factorize() -> None: def test_index_unqiue() -> None: ci = pd.CategoricalIndex(["a", "b", "a", "c"]) dti = pd.DatetimeIndex([pd.Timestamp(2000, 1, 1)]) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="pandas.Float64Index is deprecated", upper="1.5.99" ): fi = pd.Float64Index([1.0, 2.0]) i = pd.Index(["a", "b", "c", "a"]) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="pandas.Int64Index is deprecated", upper="1.5.99" ): i64i = pd.Int64Index([1, 2, 3, 4]) pi = pd.period_range("2000Q1", periods=2, freq="Q") ri = pd.RangeIndex(0, 10) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="pandas.UInt64Index is deprecated", upper="1.5.99" ): ui = pd.UInt64Index([0, 1, 2, 3, 5]) @@ -1426,7 +1426,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with pytest_warns_bounds(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1681,7 +1681,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounds(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99", match=""): check( assert_type( pd.pivot_table( @@ -1695,7 +1695,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounds(np.VisibleDeprecationWarning, upper="1.5.99"): + with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99", match=""): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 318771f20..812fef04b 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -13,7 +13,6 @@ import numpy as np from numpy import typing as npt import pandas as pd -import pytest_warns_bounds import pytz from typing_extensions import ( TypeAlias, @@ -29,6 +28,7 @@ from tests import ( TYPE_CHECKING_INVALID_USAGE, check, + pytest_warns_bounded, ) from pandas.tseries.offsets import Day @@ -338,7 +338,7 @@ def test_timedelta_add_sub() -> None: def test_timedelta_mul_div() -> None: td = pd.Timedelta("1 day") - with pytest_warns_bounds(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) @@ -455,7 +455,7 @@ def test_timedelta_mul_div() -> None: def test_timedelta_mod_abs_unary() -> None: td = pd.Timedelta("1 day") - with pytest_warns_bounds(FutureWarning, upper="1.5.99"): + with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""): i_idx = cast(pd.Int64Index, pd.Index([1, 2, 3], dtype=int)) f_idx = cast(pd.Float64Index, pd.Index([1.2, 2.2, 3.4], dtype=float)) diff --git a/tests/test_series.py b/tests/test_series.py index db8f1fe85..a7ba5d02a 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -24,7 +24,6 @@ ) from pandas.core.window import ExponentialMovingWindow import pytest -import pytest_warns_bounds from typing_extensions import assert_type import xarray as xr @@ -37,6 +36,7 @@ PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, + pytest_warns_bounded, ) if TYPE_CHECKING: @@ -261,23 +261,23 @@ def test_types_shift() -> None: def test_types_rank() -> None: s = pd.Series([1, 1, 2, 5, 6, np.nan, "milion"]) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank() - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(axis=0, na_option="bottom") - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="min", pct=True) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="Dropping of nuisance columns", upper="1.5.99" ): s.rank(method="dense", ascending=True) - with pytest_warns_bounds( + with pytest_warns_bounded( FutureWarning, match="Calling Series.rank with numeric_only", upper="1.5.99" ): s.rank(method="first", numeric_only=True) @@ -654,15 +654,15 @@ def test_types_transform() -> None: def test_types_describe() -> None: s = pd.Series([1, 2, 3, np.datetime64("2000-01-01")]) - with pytest_warns_bounds( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe() - with pytest_warns_bounds( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(percentiles=[0.5], include="all") - with pytest_warns_bounds( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(exclude=np.number) @@ -670,7 +670,7 @@ def test_types_describe() -> None: # datetime_is_numeric param added in 1.1.0 # https://pandas.pydata.org/docs/whatsnew/v1.1.0.html # Remove in 2.0.0 - with pytest_warns_bounds( + with pytest_warns_bounded( DeprecationWarning, match="elementwise comparison failed", upper="1.5.99" ): s.describe(datetime_is_numeric=True) diff --git a/tests/test_utility.py b/tests/test_utility.py index 4e50f60b8..4dcbf001d 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -1,12 +1,14 @@ import pandas as pd -import pytest_warns_bounds from typing_extensions import assert_type -from tests import check +from tests import ( + check, + pytest_warns_bounded, +) def test_show_version(): - with pytest_warns_bounds( + with pytest_warns_bounded( UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" ): check(assert_type(pd.show_versions(True), None), type(None)) From 9052ac54d5ce8f4f7a2d67f8c1f40109870c5c8b Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Tue, 22 Nov 2022 22:42:33 +0530 Subject: [PATCH 11/12] update --- tests/test_errors.py | 35 ++++++++++++++++------------------- tests/test_pandas.py | 6 +++--- tests/test_utility.py | 8 +++----- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index a2d3cefa2..7402a5a82 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -3,10 +3,7 @@ from pandas import errors import pytest -from tests import ( - WINDOWS, - pytest_warns_bounded, -) +from tests import WINDOWS def test_abstract_method_error() -> None: @@ -18,14 +15,14 @@ class Foo: def test_accessor_registration_warning() -> None: - with pytest_warns_bounded( - errors.AccessorRegistrationWarning, upper="1.5.99", match="" + with pytest.warns( + errors.AccessorRegistrationWarning ): warnings.warn("", errors.AccessorRegistrationWarning) def test_dtype_warning() -> None: - with pytest_warns_bounded(errors.DtypeWarning, upper="1.5.99", match=""): + with pytest.warns(errors.DtypeWarning): warnings.warn("", errors.DtypeWarning) @@ -85,12 +82,12 @@ def test_parser_error() -> None: def test_parser_warning() -> None: - with pytest_warns_bounded(errors.ParserWarning, upper="1.5.99", match=""): + with pytest.warns(errors.ParserWarning): warnings.warn("", errors.ParserWarning) def test_performance_warning() -> None: - with pytest_warns_bounded(errors.PerformanceWarning, upper="1.5.99", match=""): + with pytest.warns(errors.PerformanceWarning): warnings.warn("", errors.PerformanceWarning) @@ -120,7 +117,7 @@ def test_setting_with_copy_error() -> None: def test_setting_with_copy_warning() -> None: - with pytest_warns_bounded(errors.SettingWithCopyWarning, upper="1.5.99", match=""): + with pytest.warns(errors.SettingWithCopyWarning): warnings.warn("", errors.SettingWithCopyWarning) @@ -151,7 +148,7 @@ def test_pyperclip_windows_exception() -> None: def test_css_warning() -> None: - with pytest_warns_bounded(errors.CSSWarning, upper="1.5.99", match=""): + with pytest.warns(errors.CSSWarning): warnings.warn("", errors.CSSWarning) @@ -166,13 +163,13 @@ def test_closed_file_error() -> None: def test_incompatibility_warning() -> None: - with pytest_warns_bounded(errors.IncompatibilityWarning, upper="1.5.99", match=""): + with pytest.warns(errors.IncompatibilityWarning): warnings.warn("", errors.IncompatibilityWarning) def test_attribute_conflict_warning() -> None: - with pytest_warns_bounded( - errors.AttributeConflictWarning, upper="1.5.99", match="" + with pytest.warns( + errors.AttributeConflictWarning ): warnings.warn("", errors.AttributeConflictWarning) @@ -183,22 +180,22 @@ def test_database_error() -> None: def test_possible_precision_loss() -> None: - with pytest_warns_bounded(errors.PossiblePrecisionLoss, upper="1.5.99", match=""): + with pytest.warns(errors.PossiblePrecisionLoss): warnings.warn("", errors.PossiblePrecisionLoss) def test_value_label_type_mismatch() -> None: - with pytest_warns_bounded(errors.ValueLabelTypeMismatch, upper="1.5.99", match=""): + with pytest.warns(errors.ValueLabelTypeMismatch): warnings.warn("", errors.ValueLabelTypeMismatch) def test_invalid_column_name() -> None: - with pytest_warns_bounded(errors.InvalidColumnName, upper="1.5.99", match=""): + with pytest.warns(errors.InvalidColumnName): warnings.warn("", errors.InvalidColumnName) def test_categorical_conversion_warning() -> None: - with pytest_warns_bounded( - errors.CategoricalConversionWarning, upper="1.5.99", match="" + with pytest.warns( + errors.CategoricalConversionWarning ): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_pandas.py b/tests/test_pandas.py index c49b7f048..507e42125 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -1426,7 +1426,7 @@ def test_crosstab_args() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(FutureWarning, upper="1.5.99", match=""): + with pytest.warns(FutureWarning): check( assert_type( pd.crosstab(a, b, values=pd.Categorical(values), aggfunc=np.sum), @@ -1681,7 +1681,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99", match=""): + with pytest.warns(np.VisibleDeprecationWarning): check( assert_type( pd.pivot_table( @@ -1695,7 +1695,7 @@ def test_pivot_table() -> None: ), pd.DataFrame, ) - with pytest_warns_bounded(np.VisibleDeprecationWarning, upper="1.5.99", match=""): + with pytest.warns(np.VisibleDeprecationWarning): check( assert_type( pd.pivot_table( diff --git a/tests/test_utility.py b/tests/test_utility.py index 4dcbf001d..edef076df 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -1,14 +1,12 @@ import pandas as pd from typing_extensions import assert_type -from tests import ( - check, - pytest_warns_bounded, -) +from tests import check + def test_show_version(): - with pytest_warns_bounded( + with pytest.warns( UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" ): check(assert_type(pd.show_versions(True), None), type(None)) From e0d6efdb9c76e153c1f4385c32f89be3c11b0455 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Tue, 22 Nov 2022 22:49:20 +0530 Subject: [PATCH 12/12] update --- tests/test_errors.py | 12 +++--------- tests/test_utility.py | 8 +++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 7402a5a82..f507302a6 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -15,9 +15,7 @@ class Foo: def test_accessor_registration_warning() -> None: - with pytest.warns( - errors.AccessorRegistrationWarning - ): + with pytest.warns(errors.AccessorRegistrationWarning): warnings.warn("", errors.AccessorRegistrationWarning) @@ -168,9 +166,7 @@ def test_incompatibility_warning() -> None: def test_attribute_conflict_warning() -> None: - with pytest.warns( - errors.AttributeConflictWarning - ): + with pytest.warns(errors.AttributeConflictWarning): warnings.warn("", errors.AttributeConflictWarning) @@ -195,7 +191,5 @@ def test_invalid_column_name() -> None: def test_categorical_conversion_warning() -> None: - with pytest.warns( - errors.CategoricalConversionWarning - ): + with pytest.warns(errors.CategoricalConversionWarning): warnings.warn("", errors.CategoricalConversionWarning) diff --git a/tests/test_utility.py b/tests/test_utility.py index edef076df..9a27f822c 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -1,14 +1,12 @@ import pandas as pd +import pytest from typing_extensions import assert_type -from tests import check - +from tests import check def test_show_version(): - with pytest.warns( - UserWarning, match="Setuptools is replacing distutils", upper="1.5.99" - ): + with pytest.warns(UserWarning, match="Setuptools is replacing distutils"): check(assert_type(pd.show_versions(True), None), type(None)) check(assert_type(pd.show_versions(False), None), type(None))