From fe8a3ce3d133f69582e8244b737456ff57559e55 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 23 May 2024 01:57:53 -0400 Subject: [PATCH] tests: run the gc for 3.13+ Signed-off-by: Henry Schreiner --- tests/test_factory_constructors.py | 4 ++++ tests/test_virtual_functions.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/tests/test_factory_constructors.py b/tests/test_factory_constructors.py index a9004cbf67..d10aecce1f 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 get(self): 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 get(self): 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 c17af7df58..b1ac323e2e 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 get_string2(self): 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