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

Method test_ast_fini

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

Source from the content-addressed store, hash-verified

1641
1642class PythonFinalizationTests(unittest.TestCase):
1643 def test_ast_fini(self):
1644 # bpo-44184: Regression test for subtype_dealloc() when deallocating
1645 # an AST instance also destroy its AST type: subtype_dealloc() must
1646 # not access the type memory after deallocating the instance, since
1647 # the type memory can be freed as well. The test is also related to
1648 # _PyAST_Fini() which clears references to AST types.
1649 code = textwrap.dedent("""
1650 import ast
1651 import codecs
1652 from test import support
1653
1654 # Small AST tree to keep their AST types alive
1655 tree = ast.parse("def f(x, y): return 2*x-y")
1656
1657 # Store the tree somewhere to survive until the last GC collection
1658 support.late_deletion(tree)
1659 """)
1660 assert_python_ok("-c", code)
1661
1662 def test_warnings_fini(self):
1663 # See https://github.com/python/cpython/issues/137384

Callers

nothing calls this directly

Calls 2

assert_python_okFunction · 0.90
dedentMethod · 0.45

Tested by

no test coverage detected