From caea25a8b91d62b30eef99aa0c523448e19cd6db Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 26 Oct 2018 07:24:38 -0500 Subject: [PATCH] TST: Fix test assertion (#23357) --- pandas/tests/extension/base/setitem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/base/setitem.py b/pandas/tests/extension/base/setitem.py index 6ebe3cb7487ab..029a77acb121f 100644 --- a/pandas/tests/extension/base/setitem.py +++ b/pandas/tests/extension/base/setitem.py @@ -27,6 +27,7 @@ def test_setitem_sequence(self, data, box_in_series): @pytest.mark.parametrize('as_array', [True, False]) def test_setitem_sequence_mismatched_length_raises(self, data, as_array): ser = pd.Series(data) + original = ser.copy() value = [data[0]] if as_array: value = data._from_sequence(value) @@ -34,11 +35,12 @@ def test_setitem_sequence_mismatched_length_raises(self, data, as_array): xpr = 'cannot set using a {} indexer with a different length' with tm.assert_raises_regex(ValueError, xpr.format('list-like')): ser[[0, 1]] = value - assert ser._values[[0, 1]] == value + # Ensure no modifications made before the exception + self.assert_series_equal(ser, original) with tm.assert_raises_regex(ValueError, xpr.format('slice')): ser[slice(3)] = value - assert ser._values[slice(3)] == value + self.assert_series_equal(ser, original) def test_setitem_empty_indxer(self, data, box_in_series): if box_in_series: