diff --git a/tests/test_frame.py b/tests/test_frame.py index c2e4ef4f7..3c26c9088 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -1561,12 +1561,12 @@ class ReadCsvKwargs(TypedDict): assert_type(pd.read_csv(path, parse_dates=parse_dates_4), pd.DataFrame), pd.DataFrame, ) - parse_dates_5 = [2] + parse_dates_5 = [0] check( assert_type(pd.read_csv(path, parse_dates=parse_dates_5), pd.DataFrame), pd.DataFrame, ) - parse_dates_6 = [[1, 2], [1, 2, 3]] + parse_dates_6 = [[1, 2, 3]] check( assert_type(pd.read_csv(path, parse_dates=parse_dates_6), pd.DataFrame), pd.DataFrame, diff --git a/tests/test_pandas.py b/tests/test_pandas.py index a605e80c3..3b146c0b5 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -31,9 +31,14 @@ def test_types_to_datetime() -> None: df = pd.DataFrame({"year": [2015, 2016], "month": [2, 3], "day": [4, 5]}) r1: pd.Series = pd.to_datetime(df) - r2: pd.Series = pd.to_datetime( - df, unit="s", origin="unix", infer_datetime_format=True - ) + with pytest_warns_bounded( + UserWarning, + match="The argument 'infer_datetime_format' is deprecated", + lower="1.5.99", + ): + r2: pd.Series = pd.to_datetime( + df, unit="s", origin="unix", infer_datetime_format=True + ) r3: pd.Series = pd.to_datetime( df, unit="ns", dayfirst=True, utc=None, format="%M:%D", exact=False ) diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 48c21e7c9..19425c480 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -26,6 +26,7 @@ from pandas._libs.tslibs.timedeltas import Components from tests import ( + PD_LTE_15, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -1761,7 +1762,12 @@ def test_period_add_subtract() -> None: check(assert_type(p + p.freq, pd.Period), pd.Period) # offset_index is tested below offset_index = p - as_period_index - check(assert_type(p + offset_index, pd.PeriodIndex), pd.PeriodIndex) + if PD_LTE_15: + check(assert_type(p + offset_index, pd.PeriodIndex), pd.PeriodIndex) + else: + # https://github.com/pandas-dev/pandas/issues/50162 + check(assert_type(p + offset_index, pd.PeriodIndex), pd.Index) + check(assert_type(p + as_td_series, PeriodSeries), pd.Series, pd.Period) check(assert_type(p + as_timedelta_idx, pd.PeriodIndex), pd.PeriodIndex) check(assert_type(p + as_nat, NaTType), NaTType) diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 91c1be634..866815126 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -30,6 +30,7 @@ from tests import ( TYPE_CHECKING_INVALID_USAGE, check, + pytest_warns_bounded, ) from pandas.tseries.holiday import USFederalHolidayCalendar @@ -307,13 +308,18 @@ def test_to_datetime_nat() -> None: ), pd.Timestamp, ) - check( - assert_type( - pd.to_datetime("not a date", errors="coerce"), - "Union[pd.Timestamp, NaTType]", - ), - NaTType, - ) + with pytest_warns_bounded( + UserWarning, + match="Could not infer format, so each element", + lower="1.5.99", + ): + check( + assert_type( + pd.to_datetime("not a date", errors="coerce"), + "Union[pd.Timestamp, NaTType]", + ), + NaTType, + ) def test_series_dt_accessors() -> None: