Skip to content

Commit

Permalink
CLN: Split/parameterize test_to_time (#44850)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Dec 11, 2021
1 parent cbb6c73 commit 193ca73
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pandas/tests/tools/test_to_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class TestToTime:
@td.skip_if_has_locale
def test_parsers_time(self):
# GH#11818
strings = [
@pytest.mark.parametrize(
"time_string",
[
"14:15",
"1415",
"2:15pm",
Expand All @@ -25,18 +25,22 @@ def test_parsers_time(self):
"2:15:00pm",
"021500pm",
time(14, 15),
]
expected = time(14, 15)

for time_string in strings:
assert to_time(time_string) == expected
],
)
def test_parsers_time(self, time_string):
# GH#11818
assert to_time(time_string) == time(14, 15)

@td.skip_if_has_locale
def test_odd_format(self):
new_string = "14.15"
msg = r"Cannot convert arg \['14\.15'\] to a time"
with pytest.raises(ValueError, match=msg):
to_time(new_string)
assert to_time(new_string, format="%H.%M") == expected
assert to_time(new_string, format="%H.%M") == time(14, 15)

@td.skip_if_has_locale
def test_arraylike(self):
arg = ["14:15", "20:20"]
expected_arr = [time(14, 15), time(20, 20)]
assert to_time(arg) == expected_arr
Expand Down

0 comments on commit 193ca73

Please sign in to comment.