From 70ef8e202a6c1dee223a1a5404b5f2559a2f0c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Thu, 20 Jan 2022 14:06:53 -0500 Subject: [PATCH 1/3] TST: Add tests string series min max In line with #31746 --- pandas/tests/series/test_reductions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/tests/series/test_reductions.py b/pandas/tests/series/test_reductions.py index 8fb51af70f3a0..aea931d9aa4bf 100644 --- a/pandas/tests/series/test_reductions.py +++ b/pandas/tests/series/test_reductions.py @@ -9,6 +9,13 @@ import pandas._testing as tm +def test_reductions_series_strings(): + # GH#31746 + ser = Series(["a", "b"], dtype="string") + assert ser.max() == "b" + assert ser.min() == "a" + + @pytest.mark.parametrize("as_period", [True, False]) def test_mode_extension_dtype(as_period): # GH#41927 preserve dt64tz dtype From dfdddfa7507fd4075e3f2ebf7cbf78bf8c291e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Fri, 21 Jan 2022 17:50:38 -0500 Subject: [PATCH 2/3] TST: Parametrize test using functions #31746 --- pandas/tests/series/test_reductions.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pandas/tests/series/test_reductions.py b/pandas/tests/series/test_reductions.py index aea931d9aa4bf..94a2fe186962f 100644 --- a/pandas/tests/series/test_reductions.py +++ b/pandas/tests/series/test_reductions.py @@ -9,11 +9,15 @@ import pandas._testing as tm -def test_reductions_series_strings(): +@pytest.mark.parametrize("operation", ["min", "max"]) +def test_reductions_series_strings(operation): # GH#31746 - ser = Series(["a", "b"], dtype="string") - assert ser.max() == "b" - assert ser.min() == "a" + list_str = ["a", "b"] + ser = Series(list_str, dtype="string") + res_operation_serie = getattr(ser, operation)() + func_builtin_python = __builtins__[operation] + res_builtin_python = func_builtin_python(list_str) + assert res_operation_serie == res_builtin_python @pytest.mark.parametrize("as_period", [True, False]) From 4b7be33973eb7d337c4fd2a743cccf432bc1b2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Sat, 22 Jan 2022 11:17:10 -0500 Subject: [PATCH 3/3] TST: Parametrize expected output #31746 --- pandas/tests/series/test_reductions.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pandas/tests/series/test_reductions.py b/pandas/tests/series/test_reductions.py index 94a2fe186962f..151383ba18717 100644 --- a/pandas/tests/series/test_reductions.py +++ b/pandas/tests/series/test_reductions.py @@ -9,15 +9,12 @@ import pandas._testing as tm -@pytest.mark.parametrize("operation", ["min", "max"]) -def test_reductions_series_strings(operation): +@pytest.mark.parametrize("operation, expected", [("min", "a"), ("max", "b")]) +def test_reductions_series_strings(operation, expected): # GH#31746 - list_str = ["a", "b"] - ser = Series(list_str, dtype="string") + ser = Series(["a", "b"], dtype="string") res_operation_serie = getattr(ser, operation)() - func_builtin_python = __builtins__[operation] - res_builtin_python = func_builtin_python(list_str) - assert res_operation_serie == res_builtin_python + assert res_operation_serie == expected @pytest.mark.parametrize("as_period", [True, False])