From 034cc3aabf88a50f44bf9adb58d3743b00d0fac0 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Sat, 9 Jan 2021 10:53:38 -0500 Subject: [PATCH 1/3] TST: skips in extension.test_categorical --- pandas/tests/extension/base/methods.py | 5 +++- pandas/tests/extension/test_categorical.py | 34 ++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 472e783c977f0..05ce7e3bb08a9 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -394,7 +394,10 @@ def test_hash_pandas_object_works(self, data, as_frame): def test_searchsorted(self, data_for_sorting, as_series): b, c, a = data_for_sorting - arr = type(data_for_sorting)._from_sequence([a, b, c]) + # Pass dtype so sorting order is not lost for Categorical + arr = type(data_for_sorting)._from_sequence( + [a, b, c], dtype=data_for_sorting.dtype + ) if as_series: arr = pd.Series(arr) diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index e38de67071f15..477ead1b1a690 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -175,9 +175,8 @@ def test_combine_add(self, data_repeated): def test_fillna_length_mismatch(self, data_missing): super().test_fillna_length_mismatch(data_missing) - def test_searchsorted(self, data_for_sorting): - if not data_for_sorting.ordered: - raise pytest.skip(reason="searchsorted requires ordered data.") + def test_searchsorted(self, data_for_sorting, as_series): + super().test_searchsorted(data_for_sorting, as_series) class TestCasting(base.BaseCastingTests): @@ -229,21 +228,26 @@ def test_consistent_casting(self, dtype, expected): class TestArithmeticOps(base.BaseArithmeticOpsTests): - def test_arith_frame_with_scalar(self, data, all_arithmetic_operators): + def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): # frame & scalar op_name = all_arithmetic_operators - if op_name != "__rmod__": - super().test_arith_frame_with_scalar(data, all_arithmetic_operators) - else: - pytest.skip("rmod never called when string is first argument") - - def test_arith_series_with_scalar(self, data, all_arithmetic_operators): - + if op_name == "__rmod__": + request.node.add_marker( + pytest.mark.xfail( + reason="rmod never called when string is first argument" + ) + ) + super().test_arith_frame_with_scalar(data, op_name) + + def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request): op_name = all_arithmetic_operators - if op_name != "__rmod__": - super().test_arith_series_with_scalar(data, op_name) - else: - pytest.skip("rmod never called when string is first argument") + if op_name == "__rmod__": + request.node.add_marker( + pytest.mark.xfail( + reason="rmod never called when string is first argument" + ) + ) + super().test_arith_series_with_scalar(data, op_name) def test_add_series_with_extension_array(self, data): ser = pd.Series(data) From 8298998fc1194f0492731f9a897b0e80a6e477fd Mon Sep 17 00:00:00 2001 From: rhshadrach Date: Sun, 10 Jan 2021 20:04:37 -0500 Subject: [PATCH 2/3] Removed unnecessary override, simplified test_searchsorted --- pandas/tests/extension/base/methods.py | 4 +--- pandas/tests/extension/test_categorical.py | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 05ce7e3bb08a9..6d6d98e04d6ea 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -395,9 +395,7 @@ def test_hash_pandas_object_works(self, data, as_frame): def test_searchsorted(self, data_for_sorting, as_series): b, c, a = data_for_sorting # Pass dtype so sorting order is not lost for Categorical - arr = type(data_for_sorting)._from_sequence( - [a, b, c], dtype=data_for_sorting.dtype - ) + arr = data_for_sorting.take([2, 0, 1]) # to get [a, b, c] if as_series: arr = pd.Series(arr) diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index 477ead1b1a690..9cea274a118c0 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -175,9 +175,6 @@ def test_combine_add(self, data_repeated): def test_fillna_length_mismatch(self, data_missing): super().test_fillna_length_mismatch(data_missing) - def test_searchsorted(self, data_for_sorting, as_series): - super().test_searchsorted(data_for_sorting, as_series) - class TestCasting(base.BaseCastingTests): @pytest.mark.parametrize("cls", [Categorical, CategoricalIndex]) From 6fc7b722b87b3bb608fc6b75d6d7d9bc95176ac9 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Mon, 11 Jan 2021 18:38:07 -0500 Subject: [PATCH 3/3] Remove comment --- pandas/tests/extension/base/methods.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/extension/base/methods.py b/pandas/tests/extension/base/methods.py index 6d6d98e04d6ea..7e7f1f1a6e025 100644 --- a/pandas/tests/extension/base/methods.py +++ b/pandas/tests/extension/base/methods.py @@ -394,7 +394,6 @@ def test_hash_pandas_object_works(self, data, as_frame): def test_searchsorted(self, data_for_sorting, as_series): b, c, a = data_for_sorting - # Pass dtype so sorting order is not lost for Categorical arr = data_for_sorting.take([2, 0, 1]) # to get [a, b, c] if as_series: