Skip to content

Commit 432c604

Browse files
committed
fix tests
1 parent 3191ab4 commit 432c604

File tree

4 files changed

+19
-48
lines changed

4 files changed

+19
-48
lines changed

pandas/tests/indexes/period/test_period_range.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_constructor_U(self):
203203
with pytest.raises(ValueError, match="Invalid frequency: X"):
204204
period_range("2007-1-1", periods=500, freq="X")
205205

206-
@pytest.mark.parametrize("freq_depr", ["2H", "2MIN", "2S", "2US", "2NS"])
206+
@pytest.mark.parametrize("freq_depr", ["2MIN", "2US", "2NS"])
207207
def test_uppercase_freq_deprecated_from_time_series(self, freq_depr):
208208
# GH#52536, GH#54939
209209
msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "
@@ -212,9 +212,9 @@ def test_uppercase_freq_deprecated_from_time_series(self, freq_depr):
212212
with tm.assert_produces_warning(FutureWarning, match=msg):
213213
period_range("2020-01-01 00:00:00 00:00", periods=2, freq=freq_depr)
214214

215-
@pytest.mark.parametrize("freq", ["2m", "2q-sep", "2y"])
216-
def test_lowercase_freq_from_time_series_raises(self, freq):
217-
# GH#52536, GH#54939
215+
@pytest.mark.parametrize("freq", ["2m", "2q-sep", "2y", "2H", "2S"])
216+
def test_incorrect_case_freq_from_time_series_raises(self, freq):
217+
# GH#52536, GH#54939, GH#59143
218218
msg = f"Invalid frequency: {freq}"
219219

220220
with pytest.raises(ValueError, match=msg):

pandas/tests/indexes/timedeltas/test_timedelta_range.py

+10-34
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from pandas import (
55
Timedelta,
6-
TimedeltaIndex,
76
timedelta_range,
87
to_timedelta,
98
)
@@ -70,14 +69,12 @@ def test_linspace_behavior(self, periods, freq):
7069
expected = timedelta_range(start="0 days", end="4 days", freq=freq)
7170
tm.assert_index_equal(result, expected)
7271

73-
def test_timedelta_range_H_deprecated(self):
72+
def test_timedelta_range_H_raises(self):
7473
# GH#52536
75-
msg = "'H' is deprecated and will be removed in a future version."
74+
msg = "Invalid frequency: H"
7675

77-
result = timedelta_range(start="0 days", end="4 days", periods=6)
78-
with tm.assert_produces_warning(FutureWarning, match=msg):
79-
expected = timedelta_range(start="0 days", end="4 days", freq="19H12min")
80-
tm.assert_index_equal(result, expected)
76+
with pytest.raises(ValueError, match=msg):
77+
timedelta_range(start="0 days", end="4 days", freq="19H12min")
8178

8279
def test_timedelta_range_T_raises(self):
8380
msg = "Invalid frequency: T"
@@ -130,33 +127,6 @@ def test_timedelta_range_infer_freq(self):
130127
result = timedelta_range("0s", "1s", periods=31)
131128
assert result.freq is None
132129

133-
@pytest.mark.parametrize(
134-
"freq_depr, start, end, expected_values, expected_freq",
135-
[
136-
(
137-
"3.5S",
138-
"05:03:01",
139-
"05:03:10",
140-
["0 days 05:03:01", "0 days 05:03:04.500000", "0 days 05:03:08"],
141-
"3500ms",
142-
),
143-
],
144-
)
145-
def test_timedelta_range_deprecated_freq(
146-
self, freq_depr, start, end, expected_values, expected_freq
147-
):
148-
# GH#52536
149-
msg = (
150-
f"'{freq_depr[-1]}' is deprecated and will be removed in a future version."
151-
)
152-
153-
with tm.assert_produces_warning(FutureWarning, match=msg):
154-
result = timedelta_range(start=start, end=end, freq=freq_depr)
155-
expected = TimedeltaIndex(
156-
expected_values, dtype="timedelta64[ns]", freq=expected_freq
157-
)
158-
tm.assert_index_equal(result, expected)
159-
160130
@pytest.mark.parametrize(
161131
"freq_depr, start, end",
162132
[
@@ -170,9 +140,15 @@ def test_timedelta_range_deprecated_freq(
170140
"5 hours",
171141
"5 hours 8 minutes",
172142
),
143+
(
144+
"3.5S",
145+
"05:03:01",
146+
"05:03:10",
147+
),
173148
],
174149
)
175150
def test_timedelta_range_removed_freq(self, freq_depr, start, end):
151+
# GH#59143
176152
msg = f"Invalid frequency: {freq_depr}"
177153
with pytest.raises(ValueError, match=msg):
178154
timedelta_range(start=start, end=end, freq=freq_depr)

pandas/tests/scalar/period/test_asfreq.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,14 @@ def test_conv_annual(self):
111111
assert ival_A.asfreq("B", "E") == ival_A_to_B_end
112112
assert ival_A.asfreq("D", "s") == ival_A_to_D_start
113113
assert ival_A.asfreq("D", "E") == ival_A_to_D_end
114-
msg_depr = "'H' is deprecated and will be removed in a future version."
115-
with tm.assert_produces_warning(FutureWarning, match=msg_depr):
114+
with pytest.raises(ValueError, match=msg):
116115
assert ival_A.asfreq("H", "s") == ival_A_to_H_start
117116
assert ival_A.asfreq("H", "E") == ival_A_to_H_end
118117
assert ival_A.asfreq("min", "s") == ival_A_to_T_start
119118
assert ival_A.asfreq("min", "E") == ival_A_to_T_end
120119
with pytest.raises(ValueError, match=msg):
121120
assert ival_A.asfreq("T", "s") == ival_A_to_T_start
122121
assert ival_A.asfreq("T", "E") == ival_A_to_T_end
123-
msg_depr = "'S' is deprecated and will be removed in a future version."
124-
with tm.assert_produces_warning(FutureWarning, match=msg_depr):
125122
assert ival_A.asfreq("S", "S") == ival_A_to_S_start
126123
assert ival_A.asfreq("S", "E") == ival_A_to_S_end
127124

pandas/tests/tslibs/test_resolution.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
)
1010
from pandas._libs.tslibs.dtypes import NpyDatetimeUnit
1111

12-
import pandas._testing as tm
13-
1412

1513
def test_get_resolution_nano():
1614
# don't return the fallback RESO_DAY
@@ -50,9 +48,9 @@ def test_get_attrname_from_abbrev(freqstr, expected):
5048

5149

5250
@pytest.mark.parametrize("freq", ["H", "S"])
53-
def test_units_H_S_deprecated_from_attrname_to_abbrevs(freq):
54-
# GH#52536
55-
msg = f"'{freq}' is deprecated and will be removed in a future version."
51+
def test_unit_H_S_raises(freq):
52+
# GH#59143
53+
msg = f"Invalid frequency: {freq}"
5654

57-
with tm.assert_produces_warning(FutureWarning, match=msg):
55+
with pytest.raises(ValueError, match=msg):
5856
Resolution.get_reso_from_freqstr(freq)

0 commit comments

Comments
 (0)