diff --git a/pandas/tests/copy_view/test_interp_fillna.py b/pandas/tests/copy_view/test_interp_fillna.py index e15509c5140dd..d0c4fa53faab9 100644 --- a/pandas/tests/copy_view/test_interp_fillna.py +++ b/pandas/tests/copy_view/test_interp_fillna.py @@ -165,7 +165,7 @@ def test_interpolate_object_convert_no_op(using_copy_on_write, using_infer_strin df.interpolate(method="pad", inplace=True) # Now CoW makes a copy, it should not! - if using_copy_on_write: + if using_copy_on_write and not using_infer_string: assert df._mgr._has_no_reference(0) assert np.shares_memory(arr_a, get_array(df, "a")) diff --git a/pandas/tests/copy_view/test_replace.py b/pandas/tests/copy_view/test_replace.py index 9e24ce319e3bf..c260ad9604616 100644 --- a/pandas/tests/copy_view/test_replace.py +++ b/pandas/tests/copy_view/test_replace.py @@ -357,11 +357,14 @@ def test_replace_empty_list(using_copy_on_write): @pytest.mark.parametrize("value", ["d", None]) -def test_replace_object_list_inplace(using_copy_on_write, value): +def test_replace_object_list_inplace(using_copy_on_write, using_infer_string, value): df = DataFrame({"a": ["a", "b", "c"]}, dtype=object) arr = get_array(df, "a") - df.replace(["c"], value, inplace=True) - if using_copy_on_write or value is None: + # with future.infer_string we get warning about object dtype getting cast + warning = FutureWarning if using_infer_string and value is not None else None + with tm.assert_produces_warning(warning): + df.replace(["c"], value, inplace=True) + if (using_copy_on_write or value is None) and not warning: assert np.shares_memory(arr, get_array(df, "a")) else: # This could be inplace