Skip to content

Commit fba129c

Browse files
GH1352 Fix nightly
1 parent c6398b3 commit fba129c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

tests/test_scalars.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from pandas._typing import TimeUnit
2525

2626
from tests import (
27+
PD_LTE_23,
2728
TYPE_CHECKING_INVALID_USAGE,
2829
check,
2930
np_1darray,
@@ -44,13 +45,17 @@
4445
TimedeltaSeries,
4546
TimestampSeries,
4647
)
47-
4848
else:
4949
TimedeltaSeries: TypeAlias = pd.Series
5050
TimestampSeries: TypeAlias = pd.Series
5151
PeriodSeries: TypeAlias = pd.Series
5252
OffsetSeries: TypeAlias = pd.Series
5353

54+
if not PD_LTE_23:
55+
from pandas.errors import Pandas4Warning # type: ignore[attr-defined] # pyright: ignore # isort: skip
56+
else:
57+
Pandas4Warning: TypeAlias = FutureWarning # type: ignore[no-redef]
58+
5459

5560
def test_interval() -> None:
5661
interval_i = pd.Interval(0, 1, closed="left")
@@ -369,10 +374,15 @@ def test_interval_cmp():
369374

370375
def test_timedelta_construction() -> None:
371376
check(assert_type(pd.Timedelta(1, "W"), pd.Timedelta), pd.Timedelta)
372-
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"):
377+
with pytest_warns_bounded(
378+
Pandas4Warning, # should be Pandas4Warning but only exposed starting pandas 3.0.0
379+
"'w' is deprecated and will",
380+
lower="2.3.99",
381+
upper="3.0.99",
382+
):
373383
check(assert_type(pd.Timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
374384
check(assert_type(pd.Timedelta(1, "D"), pd.Timedelta), pd.Timedelta)
375-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
385+
with pytest_warns_bounded(Pandas4Warning, "'d' is deprecated", lower="2.3.99"):
376386
check(assert_type(pd.Timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
377387
check(assert_type(pd.Timedelta(1, "days"), pd.Timedelta), pd.Timedelta)
378388
check(assert_type(pd.Timedelta(1, "day"), pd.Timedelta), pd.Timedelta)
@@ -406,10 +416,10 @@ def test_timedelta_construction() -> None:
406416
check(assert_type(pd.Timedelta(1, "nanosecond"), pd.Timedelta), pd.Timedelta)
407417

408418
check(assert_type(pd.Timedelta("1 W"), pd.Timedelta), pd.Timedelta)
409-
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"):
419+
with pytest_warns_bounded(Pandas4Warning, "'w' is deprecated", lower="2.3.99"):
410420
check(assert_type(pd.Timedelta("1 w"), pd.Timedelta), pd.Timedelta)
411421
check(assert_type(pd.Timedelta("1 D"), pd.Timedelta), pd.Timedelta)
412-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
422+
with pytest_warns_bounded(Pandas4Warning, "'d' is deprecated", lower="2.3.99"):
413423
check(assert_type(pd.Timedelta("1 d"), pd.Timedelta), pd.Timedelta)
414424
check(assert_type(pd.Timedelta("1 days"), pd.Timedelta), pd.Timedelta)
415425
check(assert_type(pd.Timedelta("1 day"), pd.Timedelta), pd.Timedelta)

tests/test_timefuncs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ def test_index_types_to_numpy() -> None:
11081108

11091109
def test_to_timedelta_units() -> None:
11101110
check(assert_type(pd.to_timedelta(1, "W"), pd.Timedelta), pd.Timedelta)
1111-
with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"):
1111+
with pytest_warns_bounded(Pandas4Warning, "'w' is deprecated", lower="2.3.99"):
11121112
check(assert_type(pd.to_timedelta(1, "w"), pd.Timedelta), pd.Timedelta)
11131113
check(assert_type(pd.to_timedelta(1, "D"), pd.Timedelta), pd.Timedelta)
1114-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
1114+
with pytest_warns_bounded(Pandas4Warning, "'d' is deprecated", lower="2.3.99"):
11151115
check(assert_type(pd.to_timedelta(1, "d"), pd.Timedelta), pd.Timedelta)
11161116
check(assert_type(pd.to_timedelta(1, "days"), pd.Timedelta), pd.Timedelta)
11171117
check(assert_type(pd.to_timedelta(1, "day"), pd.Timedelta), pd.Timedelta)
@@ -1871,7 +1871,7 @@ def test_timestamp_to_list_add() -> None:
18711871
tslist = list(pd.to_datetime(["2022-01-01", "2022-01-02"]))
18721872
check(assert_type(tslist, list[pd.Timestamp]), list, pd.Timestamp)
18731873
sseries = pd.Series(tslist)
1874-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
1874+
with pytest_warns_bounded(Pandas4Warning, "'d' is deprecated", lower="2.3.99"):
18751875
sseries + pd.Timedelta(1, "d")
18761876

18771877
check(

0 commit comments

Comments
 (0)