Kaydet (Commit) 9ed37433 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

test AST base type garbage collection

üst 68aecb56
import os import os
import sys import sys
import unittest import unittest
from test import support
import ast import ast
import weakref
from test import support
def to_tuple(t): def to_tuple(t):
if t is None or isinstance(t, (str, int, complex)): if t is None or isinstance(t, (str, int, complex)):
...@@ -207,6 +209,17 @@ class AST_Tests(unittest.TestCase): ...@@ -207,6 +209,17 @@ class AST_Tests(unittest.TestCase):
# "_ast.AST constructor takes 0 positional arguments" # "_ast.AST constructor takes 0 positional arguments"
ast.AST(2) 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): def test_snippets(self):
for input, output, kind in ((exec_tests, exec_results, "exec"), for input, output, kind in ((exec_tests, exec_results, "exec"),
(single_tests, single_results, "single"), (single_tests, single_results, "single"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment