Skip to content

Commit 193ca73

Browse files
authored
CLN: Split/parameterize test_to_time (#44850)
1 parent cbb6c73 commit 193ca73

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pandas/tests/tools/test_to_time.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
class TestToTime:
1515
@td.skip_if_has_locale
16-
def test_parsers_time(self):
17-
# GH#11818
18-
strings = [
16+
@pytest.mark.parametrize(
17+
"time_string",
18+
[
1919
"14:15",
2020
"1415",
2121
"2:15pm",
@@ -25,18 +25,22 @@ def test_parsers_time(self):
2525
"2:15:00pm",
2626
"021500pm",
2727
time(14, 15),
28-
]
29-
expected = time(14, 15)
30-
31-
for time_string in strings:
32-
assert to_time(time_string) == expected
28+
],
29+
)
30+
def test_parsers_time(self, time_string):
31+
# GH#11818
32+
assert to_time(time_string) == time(14, 15)
3333

34+
@td.skip_if_has_locale
35+
def test_odd_format(self):
3436
new_string = "14.15"
3537
msg = r"Cannot convert arg \['14\.15'\] to a time"
3638
with pytest.raises(ValueError, match=msg):
3739
to_time(new_string)
38-
assert to_time(new_string, format="%H.%M") == expected
40+
assert to_time(new_string, format="%H.%M") == time(14, 15)
3941

42+
@td.skip_if_has_locale
43+
def test_arraylike(self):
4044
arg = ["14:15", "20:20"]
4145
expected_arr = [time(14, 15), time(20, 20)]
4246
assert to_time(arg) == expected_arr

0 commit comments

Comments
 (0)