diff --git a/pandas/conftest.py b/pandas/conftest.py index 003474b57c8e1..d17468d7ca67f 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -1905,6 +1905,7 @@ def warn_copy_on_write() -> bool: """ Fixture to check if Copy-on-Write is enabled. """ + pd.options.mode.copy_on_write = "warn" return ( pd.options.mode.copy_on_write == "warn" and _get_option("mode.data_manager", silent=True) == "block" diff --git a/pandas/tests/copy_view/test_indexing.py b/pandas/tests/copy_view/test_indexing.py index 33b8ce218f029..6f3850ab64daa 100644 --- a/pandas/tests/copy_view/test_indexing.py +++ b/pandas/tests/copy_view/test_indexing.py @@ -1145,13 +1145,12 @@ def test_set_value_copy_only_necessary_column( view = df[:] if val == "a" and indexer[0] != slice(None): - # TODO(CoW-warn) assert the FutureWarning for CoW is also raised with tm.assert_produces_warning( FutureWarning, match="Setting an item of incompatible dtype is deprecated" ): indexer_func(df)[indexer] = val else: - with tm.assert_cow_warning(warn_copy_on_write): + with tm.assert_cow_warning(warn_copy_on_write and val == 100): indexer_func(df)[indexer] = val if using_copy_on_write: