From 193ca730d0b0b14ca99a5d28509b5278636dc4f6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 11 Dec 2021 08:20:13 -0800 Subject: [PATCH] CLN: Split/parameterize test_to_time (#44850) --- pandas/tests/tools/test_to_time.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pandas/tests/tools/test_to_time.py b/pandas/tests/tools/test_to_time.py index bfd347fd122c3..317b6daf05bc9 100644 --- a/pandas/tests/tools/test_to_time.py +++ b/pandas/tests/tools/test_to_time.py @@ -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", @@ -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