diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-14 18:37:52 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-14 18:37:52 (GMT) |
commit | 93963569487bd3d13962c92d64a128e27330cf02 (patch) | |
tree | 6966ad6d6148e5ede6183a80a62890470f10d612 /Lib/test/test_generators.py | |
parent | b710d7e4c320fb299cf1ab2ec12e3821dc338bc8 (diff) | |
download | cpython-93963569487bd3d13962c92d64a128e27330cf02.zip cpython-93963569487bd3d13962c92d64a128e27330cf02.tar.gz cpython-93963569487bd3d13962c92d64a128e27330cf02.tar.bz2 |
Backout c89febab4648 following private feedback by Guido.
(Issue #17807: Generators can now be finalized even when they are part of a reference cycle)
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r-- | Lib/test/test_generators.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 4e92117..edf3443 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -1,55 +1,3 @@ -import gc -import sys -import unittest -import weakref - -from test import support - - -class FinalizationTest(unittest.TestCase): - - def test_frame_resurrect(self): - # A generator frame can be resurrected by a generator's finalization. - def gen(): - nonlocal frame - try: - yield - finally: - frame = sys._getframe() - - g = gen() - wr = weakref.ref(g) - next(g) - del g - support.gc_collect() - self.assertIs(wr(), None) - self.assertTrue(frame) - del frame - support.gc_collect() - - def test_refcycle(self): - # A generator caught in a refcycle gets finalized anyway. - old_garbage = gc.garbage[:] - finalized = False - def gen(): - nonlocal finalized - try: - g = yield - yield 1 - finally: - finalized = True - - g = gen() - next(g) - g.send(g) - self.assertGreater(sys.getrefcount(g), 2) - self.assertFalse(finalized) - del g - support.gc_collect() - self.assertTrue(finalized) - self.assertEqual(gc.garbage, old_garbage) - - tutorial_tests = """ Let's try a simple generator: @@ -1932,7 +1880,6 @@ __test__ = {"tut": tutorial_tests, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): from test import support, test_generators - support.run_unittest(__name__) support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. |