diff --git a/tests/test_factory_constructors.py b/tests/test_factory_constructors.py index a9004cbf6..d10aecce1 100644 --- a/tests/test_factory_constructors.py +++ b/tests/test_factory_constructors.py @@ -1,3 +1,4 @@ +import gc import re import pytest @@ -209,6 +210,7 @@ def test_init_factory_alias(): assert ConstructorStats.detail_reg_inst() == n_inst + 3 assert [i.alive() for i in cstats] == [3, 3] del x, y, z + gc.collect() assert [i.alive() for i in cstats] == [0, 0] assert ConstructorStats.detail_reg_inst() == n_inst @@ -288,9 +290,11 @@ def test_init_factory_dual(): assert ConstructorStats.detail_reg_inst() == n_inst + 13 del a1, a2, b1, d1, e1, e2 + gc.collect() assert [i.alive() for i in cstats] == [7, 4] assert ConstructorStats.detail_reg_inst() == n_inst + 7 del b2, c1, c2, d2, f1, f2, g1 + gc.collect() assert [i.alive() for i in cstats] == [0, 0] assert ConstructorStats.detail_reg_inst() == n_inst diff --git a/tests/test_virtual_functions.py b/tests/test_virtual_functions.py index c17af7df5..b1ac323e2 100644 --- a/tests/test_virtual_functions.py +++ b/tests/test_virtual_functions.py @@ -1,3 +1,5 @@ +import gc + import pytest import env # noqa: F401 @@ -81,6 +83,7 @@ def test_override(capture, msg): cstats = ConstructorStats.get(m.ExampleVirt) assert cstats.alive() == 3 del ex12, ex12p, ex12p2 + gc.collect() # Python 3.13 incremental gc needs this assert cstats.alive() == 0 assert cstats.values() == ["10", "11", "17"] assert cstats.copy_constructions == 0