diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 46e4779cdef8..ab80dca593f4 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -1813,29 +1813,29 @@ def __repr__(self) -> str: foos = [Foo(1), Foo(2), Foo(3)] # foos and sys.getrefcount have a reference. base_count = 2 - assert sys.getrefcount(foos[0]) == base_count + assert sys.getrefcount(foos[0]) >= base_count df = pl.DataFrame({"groups": [1, 1, 2], "a": foos}) - assert sys.getrefcount(foos[0]) == base_count + 1 + assert sys.getrefcount(foos[0]) >= base_count + 1 del df - assert sys.getrefcount(foos[0]) == base_count + assert sys.getrefcount(foos[0]) >= base_count df = pl.DataFrame({"groups": [1, 1, 2], "a": foos}) - assert sys.getrefcount(foos[0]) == base_count + 1 + assert sys.getrefcount(foos[0]) >= base_count + 1 out = df.group_by("groups", maintain_order=True).agg(pl.col("a").alias("a")) - assert sys.getrefcount(foos[0]) == base_count + 2 + assert sys.getrefcount(foos[0]) >= base_count + 2 s = out["a"].list.explode() - assert sys.getrefcount(foos[0]) == base_count + 3 + assert sys.getrefcount(foos[0]) >= base_count + 3 del s - assert sys.getrefcount(foos[0]) == base_count + 2 + assert sys.getrefcount(foos[0]) >= base_count + 2 assert out["a"].list.explode().to_list() == foos - assert sys.getrefcount(foos[0]) == base_count + 2 + assert sys.getrefcount(foos[0]) >= base_count + 2 del out - assert sys.getrefcount(foos[0]) == base_count + 1 + assert sys.getrefcount(foos[0]) >= base_count + 1 del df - assert sys.getrefcount(foos[0]) == base_count + assert sys.getrefcount(foos[0]) >= base_count @pytest.mark.parametrize("name", [None, "n", ""])