Skip to content

Commit

Permalink
TST: Fix test assertion (pandas-dev#23357)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger authored and Pingviinituutti committed Feb 28, 2019
1 parent 3c00547 commit 40ca91a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pandas/tests/extension/base/setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ 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)

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:
Expand Down

0 comments on commit 40ca91a

Please sign in to comment.