From 0671e7d67df8b0aa258fd864ef5f3169fe0ffc55 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 2 Oct 2018 11:10:42 -0500 Subject: [PATCH] Fixup --- .../tests/extension/decimal/test_decimal.py | 19 +++++++++++++++- pandas/tests/extension/test_ops.py | 22 ------------------- 2 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 pandas/tests/extension/test_ops.py diff --git a/pandas/tests/extension/decimal/test_decimal.py b/pandas/tests/extension/decimal/test_decimal.py index 45a421dae0272..036e2d97b4d0f 100644 --- a/pandas/tests/extension/decimal/test_decimal.py +++ b/pandas/tests/extension/decimal/test_decimal.py @@ -8,7 +8,7 @@ from pandas.tests.extension import base -from .array import DecimalDtype, DecimalArray +from .array import DecimalDtype, DecimalArray, to_decimal def make_data(): @@ -244,6 +244,23 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators): context.traps[decimal.DivisionByZero] = divbyzerotrap context.traps[decimal.InvalidOperation] = invalidoptrap + @pytest.mark.parametrize("reverse, expected_div, expected_mod", [ + (False, [0, 1, 1, 2], [1, 0, 1, 0]), + (True, [2, 1, 0, 0], [0, 0, 2, 2]), + ]) + def test_divmod_array(self, reverse, expected_div, expected_mod): + # https://github.com/pandas-dev/pandas/issues/22930 + arr = to_decimal([1, 2, 3, 4]) + if reverse: + div, mod = divmod(2, arr) + else: + div, mod = divmod(arr, 2) + expected_div = to_decimal(expected_div) + expected_mod = to_decimal(expected_mod) + + tm.assert_extension_array_equal(div, expected_div) + tm.assert_extension_array_equal(mod, expected_mod) + def test_divmod(self, data): s = pd.Series(data, name='name') a, b = divmod(s, 2) diff --git a/pandas/tests/extension/test_ops.py b/pandas/tests/extension/test_ops.py deleted file mode 100644 index 931194b474af4..0000000000000 --- a/pandas/tests/extension/test_ops.py +++ /dev/null @@ -1,22 +0,0 @@ -import pytest - -from pandas.tests.extension.decimal.array import to_decimal -import pandas.util.testing as tm - - -@pytest.mark.parametrize("reverse, expected_div, expected_mod", [ - (False, [0, 1, 1, 2], [1, 0, 1, 0]), - (True, [2, 1, 0, 0], [0, 0, 2, 2]), -]) -def test_divmod(reverse, expected_div, expected_mod): - # https://github.com/pandas-dev/pandas/issues/22930 - arr = to_decimal([1, 2, 3, 4]) - if reverse: - div, mod = divmod(2, arr) - else: - div, mod = divmod(arr, 2) - expected_div = to_decimal(expected_div) - expected_mod = to_decimal(expected_mod) - - tm.assert_extension_array_equal(div, expected_div) - tm.assert_extension_array_equal(mod, expected_mod)