Skip to content

Commit 400ae74

Browse files
authored
CoW: Update test with read-only array (#56418)
1 parent b4c9df8 commit 400ae74

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/tests/frame/methods/test_to_dict_of_blocks.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def test_no_copy_blocks(self, float_frame, using_copy_on_write):
3535
assert _last_df is not None and not _last_df[column].equals(df[column])
3636

3737

38-
def test_to_dict_of_blocks_item_cache(request, using_copy_on_write, warn_copy_on_write):
39-
if using_copy_on_write:
40-
request.applymarker(pytest.mark.xfail(reason="CoW - not yet implemented"))
38+
def test_to_dict_of_blocks_item_cache(using_copy_on_write, warn_copy_on_write):
4139
# Calling to_dict_of_blocks should not poison item_cache
4240
df = DataFrame({"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"]})
4341
df["c"] = NumpyExtensionArray(np.array([1, 2, None, 3], dtype=object))
@@ -49,10 +47,8 @@ def test_to_dict_of_blocks_item_cache(request, using_copy_on_write, warn_copy_on
4947
df._to_dict_of_blocks()
5048

5149
if using_copy_on_write:
52-
# TODO(CoW) we should disallow this, so `df` doesn't get updated,
53-
# this currently still updates df, so this test fails
54-
ser.values[0] = "foo"
55-
assert df.loc[0, "b"] == "a"
50+
with pytest.raises(ValueError, match="read-only"):
51+
ser.values[0] = "foo"
5652
elif warn_copy_on_write:
5753
ser.values[0] = "foo"
5854
assert df.loc[0, "b"] == "foo"

0 commit comments

Comments
 (0)