Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Fix test assertion #23357

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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