|
24 | 24 | from pandas._typing import TimeUnit |
25 | 25 |
|
26 | 26 | from tests import ( |
| 27 | + PD_LTE_23, |
27 | 28 | TYPE_CHECKING_INVALID_USAGE, |
28 | 29 | check, |
29 | 30 | np_1darray, |
|
44 | 45 | TimedeltaSeries, |
45 | 46 | TimestampSeries, |
46 | 47 | ) |
47 | | - |
48 | 48 | else: |
49 | 49 | TimedeltaSeries: TypeAlias = pd.Series |
50 | 50 | TimestampSeries: TypeAlias = pd.Series |
51 | 51 | PeriodSeries: TypeAlias = pd.Series |
52 | 52 | OffsetSeries: TypeAlias = pd.Series |
53 | 53 |
|
| 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 | + |
54 | 59 |
|
55 | 60 | def test_interval() -> None: |
56 | 61 | interval_i = pd.Interval(0, 1, closed="left") |
@@ -369,10 +374,15 @@ def test_interval_cmp(): |
369 | 374 |
|
370 | 375 | def test_timedelta_construction() -> None: |
371 | 376 | 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 | + ): |
373 | 383 | check(assert_type(pd.Timedelta(1, "w"), pd.Timedelta), pd.Timedelta) |
374 | 384 | 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"): |
376 | 386 | check(assert_type(pd.Timedelta(1, "d"), pd.Timedelta), pd.Timedelta) |
377 | 387 | check(assert_type(pd.Timedelta(1, "days"), pd.Timedelta), pd.Timedelta) |
378 | 388 | check(assert_type(pd.Timedelta(1, "day"), pd.Timedelta), pd.Timedelta) |
@@ -406,10 +416,10 @@ def test_timedelta_construction() -> None: |
406 | 416 | check(assert_type(pd.Timedelta(1, "nanosecond"), pd.Timedelta), pd.Timedelta) |
407 | 417 |
|
408 | 418 | 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"): |
410 | 420 | check(assert_type(pd.Timedelta("1 w"), pd.Timedelta), pd.Timedelta) |
411 | 421 | 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"): |
413 | 423 | check(assert_type(pd.Timedelta("1 d"), pd.Timedelta), pd.Timedelta) |
414 | 424 | check(assert_type(pd.Timedelta("1 days"), pd.Timedelta), pd.Timedelta) |
415 | 425 | check(assert_type(pd.Timedelta("1 day"), pd.Timedelta), pd.Timedelta) |
|
0 commit comments