diff --git a/python/cudf/cudf/tests/test_list.py b/python/cudf/cudf/tests/test_list.py index 3ef579574c6..fc9ad9711d1 100644 --- a/python/cudf/cudf/tests/test_list.py +++ b/python/cudf/cudf/tests/test_list.py @@ -593,7 +593,12 @@ def test_listcol_setitem_retain_dtype(): df = cudf.DataFrame( {"a": cudf.Series([["a", "b"], []]), "b": [1, 2], "c": [123, 321]} ) - df1 = df[df.b.isna()] + df1 = df.head(0) + # Performing a setitem on `b` triggers a `column.column_empty_like` call + # which tries to create an empty ListColumn. df1["b"] = df1["c"] - df2 = df1.drop(["c"], axis=1) - assert df2.a.dtype == df.a.dtype + # Performing a copy to trigger a copy dtype which is obtained by accessing + # `ListColumn.children` that would have been corrupted in previous call + # prior to this fix: https://github.com/rapidsai/cudf/pull/10151/ + df2 = df1.copy() + assert df2["a"].dtype == df["a"].dtype