Skip to content

Commit 9ba09f4

Browse files
authored
Fix nightly runs (#485)
* fix nightly tests * restrict args for parse_dates, remove space in warning
1 parent c426dbd commit 9ba09f4

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

tests/test_frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1562,12 +1562,12 @@ class ReadCsvKwargs(TypedDict):
15621562
assert_type(pd.read_csv(path, parse_dates=parse_dates_4), pd.DataFrame),
15631563
pd.DataFrame,
15641564
)
1565-
parse_dates_5 = [2]
1565+
parse_dates_5 = [0]
15661566
check(
15671567
assert_type(pd.read_csv(path, parse_dates=parse_dates_5), pd.DataFrame),
15681568
pd.DataFrame,
15691569
)
1570-
parse_dates_6 = [[1, 2], [1, 2, 3]]
1570+
parse_dates_6 = [[1, 2, 3]]
15711571
check(
15721572
assert_type(pd.read_csv(path, parse_dates=parse_dates_6), pd.DataFrame),
15731573
pd.DataFrame,

tests/test_pandas.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@
3131
def test_types_to_datetime() -> None:
3232
df = pd.DataFrame({"year": [2015, 2016], "month": [2, 3], "day": [4, 5]})
3333
r1: pd.Series = pd.to_datetime(df)
34-
r2: pd.Series = pd.to_datetime(
35-
df, unit="s", origin="unix", infer_datetime_format=True
36-
)
34+
with pytest_warns_bounded(
35+
UserWarning,
36+
match="The argument 'infer_datetime_format' is deprecated",
37+
lower="1.5.99",
38+
):
39+
r2: pd.Series = pd.to_datetime(
40+
df, unit="s", origin="unix", infer_datetime_format=True
41+
)
3742
r3: pd.Series = pd.to_datetime(
3843
df, unit="ns", dayfirst=True, utc=None, format="%M:%D", exact=False
3944
)

tests/test_scalars.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pandas._libs.tslibs.timedeltas import Components
2727

2828
from tests import (
29+
PD_LTE_15,
2930
TYPE_CHECKING_INVALID_USAGE,
3031
check,
3132
pytest_warns_bounded,
@@ -1761,7 +1762,12 @@ def test_period_add_subtract() -> None:
17611762
check(assert_type(p + p.freq, pd.Period), pd.Period)
17621763
# offset_index is tested below
17631764
offset_index = p - as_period_index
1764-
check(assert_type(p + offset_index, pd.PeriodIndex), pd.PeriodIndex)
1765+
if PD_LTE_15:
1766+
check(assert_type(p + offset_index, pd.PeriodIndex), pd.PeriodIndex)
1767+
else:
1768+
# https://github.com/pandas-dev/pandas/issues/50162
1769+
check(assert_type(p + offset_index, pd.PeriodIndex), pd.Index)
1770+
17651771
check(assert_type(p + as_td_series, PeriodSeries), pd.Series, pd.Period)
17661772
check(assert_type(p + as_timedelta_idx, pd.PeriodIndex), pd.PeriodIndex)
17671773
check(assert_type(p + as_nat, NaTType), NaTType)

tests/test_timefuncs.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from tests import (
3131
TYPE_CHECKING_INVALID_USAGE,
3232
check,
33+
pytest_warns_bounded,
3334
)
3435

3536
from pandas.tseries.holiday import USFederalHolidayCalendar
@@ -307,13 +308,18 @@ def test_to_datetime_nat() -> None:
307308
),
308309
pd.Timestamp,
309310
)
310-
check(
311-
assert_type(
312-
pd.to_datetime("not a date", errors="coerce"),
313-
"Union[pd.Timestamp, NaTType]",
314-
),
315-
NaTType,
316-
)
311+
with pytest_warns_bounded(
312+
UserWarning,
313+
match="Could not infer format, so each element",
314+
lower="1.5.99",
315+
):
316+
check(
317+
assert_type(
318+
pd.to_datetime("not a date", errors="coerce"),
319+
"Union[pd.Timestamp, NaTType]",
320+
),
321+
NaTType,
322+
)
317323

318324

319325
def test_series_dt_accessors() -> None:

0 commit comments

Comments
 (0)