MCPcopy Index your code
hub / github.com/python/cpython / test_deferred_refcount_frozen

Method test_deferred_refcount_frozen

Lib/test/test_gc.py:1176–1200  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1174 gc.unfreeze()
1175
1176 def test_deferred_refcount_frozen(self):
1177 # Also from GH-126312: objects that use deferred reference counting
1178 # weren't ignored if they were frozen. Unfortunately, it's pretty
1179 # difficult to come up with a case that triggers this.
1180 #
1181 # Calling gc.collect() while the garbage collector is frozen doesn't
1182 # trigger this normally, but it *does* if it's inside unittest for whatever
1183 # reason. We can't call unittest from inside a test, so it has to be
1184 # in a subprocess.
1185 source = textwrap.dedent("""
1186 import gc
1187 import unittest
1188
1189
1190 class Test(unittest.TestCase):
1191 def test_something(self):
1192 gc.freeze()
1193 gc.collect()
1194 gc.unfreeze()
1195
1196
1197 if __name__ == "__main__":
1198 unittest.main()
1199 """)
1200 assert_python_ok("-c", source)
1201
1202 def test_do_not_cleanup_type_subclasses_before_finalization(self):
1203 # See https://github.com/python/cpython/issues/135552

Callers

nothing calls this directly

Calls 2

assert_python_okFunction · 0.90
dedentMethod · 0.45

Tested by

no test coverage detected