From 64897f9d8677535871488f3046d629c6c6f60627 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 8 Dec 2023 23:52:40 +0100 Subject: [PATCH] CoW: Update test with read-only array --- pandas/tests/frame/methods/test_to_dict_of_blocks.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pandas/tests/frame/methods/test_to_dict_of_blocks.py b/pandas/tests/frame/methods/test_to_dict_of_blocks.py index 28973fe0d7900..7d08efe916a76 100644 --- a/pandas/tests/frame/methods/test_to_dict_of_blocks.py +++ b/pandas/tests/frame/methods/test_to_dict_of_blocks.py @@ -51,9 +51,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)) @@ -65,10 +63,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"