diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index c9d034361d8c4..75fc7a782772a 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -2418,10 +2418,16 @@ def test_diff_low_precision_int(self, dtype): tm.assert_numpy_array_equal(result, expected) -def test_union_with_duplicates(): +@pytest.mark.parametrize("op", [np.array, pd.array]) +def test_union_with_duplicates(op): # GH#36289 - lvals = np.array([3, 1, 3, 4]) - rvals = np.array([2, 3, 1, 1]) - result = algos.union_with_duplicates(lvals, rvals) - expected = np.array([3, 3, 1, 1, 4, 2]) - tm.assert_numpy_array_equal(result, expected) + lvals = op([3, 1, 3, 4]) + rvals = op([2, 3, 1, 1]) + expected = op([3, 3, 1, 1, 4, 2]) + if isinstance(expected, np.ndarray): + result = algos.union_with_duplicates(lvals, rvals) + tm.assert_numpy_array_equal(result, expected) + else: + with tm.assert_produces_warning(RuntimeWarning): + result = algos.union_with_duplicates(lvals, rvals) + tm.assert_extension_array_equal(result, expected)