Skip to content

Commit

Permalink
CoW: Update test with read-only array (#56418)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Dec 11, 2023
1 parent b4c9df8 commit 400ae74
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pandas/tests/frame/methods/test_to_dict_of_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def test_no_copy_blocks(self, float_frame, using_copy_on_write):
assert _last_df is not None and not _last_df[column].equals(df[column])


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

if using_copy_on_write:
# TODO(CoW) we should disallow this, so `df` doesn't get updated,
# this currently still updates df, so this test fails
ser.values[0] = "foo"
assert df.loc[0, "b"] == "a"
with pytest.raises(ValueError, match="read-only"):
ser.values[0] = "foo"
elif warn_copy_on_write:
ser.values[0] = "foo"
assert df.loc[0, "b"] == "foo"
Expand Down

0 comments on commit 400ae74

Please sign in to comment.