Skip to content

CLN: Split/parameterize test_to_time #44850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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