diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-07-08 18:13:36 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-07-08 18:13:36 (GMT) |
commit | 9ed37433c4db71076f554eb7c9343b6381ba32e1 (patch) | |
tree | 9a53c80d374f6c1228a8183eb450b1dba4088b7a | |
parent | 68aecb5619efa3b203964f94b7aef5fdd42b2fde (diff) | |
download | cpython-9ed37433c4db71076f554eb7c9343b6381ba32e1.zip cpython-9ed37433c4db71076f554eb7c9343b6381ba32e1.tar.gz cpython-9ed37433c4db71076f554eb7c9343b6381ba32e1.tar.bz2 |
test AST base type garbage collection
-rw-r--r-- | Lib/test/test_ast.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 3b9f10c..aa08166 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1,8 +1,10 @@ import os import sys import unittest -from test import support import ast +import weakref + +from test import support def to_tuple(t): if t is None or isinstance(t, (str, int, complex)): @@ -207,6 +209,17 @@ class AST_Tests(unittest.TestCase): # "_ast.AST constructor takes 0 positional arguments" ast.AST(2) + def test_AST_garbage_collection(self): + class X: + pass + a = ast.AST() + a.x = X() + a.x.a = a + ref = weakref.ref(a.x) + del a + support.gc_collect() + self.assertIsNone(ref()) + def test_snippets(self): for input, output, kind in ((exec_tests, exec_results, "exec"), (single_tests, single_results, "single"), |