|
1 | 1 | """ test the scalar Timedelta """
|
2 | 2 | from datetime import timedelta
|
3 |
| -import re |
4 | 3 |
|
5 | 4 | import numpy as np
|
6 | 5 | import pytest
|
@@ -318,12 +317,9 @@ def test_nat_converters(self):
|
318 | 317 | assert result.dtype.kind == "M"
|
319 | 318 | assert result.astype("int64") == iNaT
|
320 | 319 |
|
321 |
| - @pytest.mark.filterwarnings("ignore:M and Y units are deprecated") |
322 | 320 | @pytest.mark.parametrize(
|
323 | 321 | "units, np_unit",
|
324 | 322 | [
|
325 |
| - (["Y", "y"], "Y"), |
326 |
| - (["M"], "M"), |
327 | 323 | (["W", "w"], "W"),
|
328 | 324 | (["D", "d", "days", "day", "Days", "Day"], "D"),
|
329 | 325 | (
|
@@ -426,19 +422,16 @@ def test_unit_parser(self, units, np_unit, wrapper):
|
426 | 422 | assert result == expected
|
427 | 423 |
|
428 | 424 | @pytest.mark.parametrize("unit", ["Y", "y", "M"])
|
429 |
| - def test_unit_m_y_deprecated(self, unit): |
430 |
| - with tm.assert_produces_warning(FutureWarning) as w1: |
| 425 | + def test_unit_m_y_raises(self, unit): |
| 426 | + msg = "Units 'M' and 'Y' are no longer supported" |
| 427 | + with pytest.raises(ValueError, match=msg): |
431 | 428 | Timedelta(10, unit)
|
432 |
| - msg = r".* units are deprecated .*" |
433 |
| - assert re.match(msg, str(w1[0].message)) |
434 |
| - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False) as w2: |
| 429 | + |
| 430 | + with pytest.raises(ValueError, match=msg): |
435 | 431 | to_timedelta(10, unit)
|
436 |
| - msg = r".* units are deprecated .*" |
437 |
| - assert re.match(msg, str(w2[0].message)) |
438 |
| - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False) as w3: |
| 432 | + |
| 433 | + with pytest.raises(ValueError, match=msg): |
439 | 434 | to_timedelta([1, 2], unit)
|
440 |
| - msg = r".* units are deprecated .*" |
441 |
| - assert re.match(msg, str(w3[0].message)) |
442 | 435 |
|
443 | 436 | def test_numeric_conversions(self):
|
444 | 437 | assert Timedelta(0) == np.timedelta64(0, "ns")
|
|
0 commit comments