Skip to content

for issue 429 #433

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 12 additions & 12 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand All @@ -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)


Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
12 changes: 6 additions & 6 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]])
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down
18 changes: 9 additions & 9 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down