summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-08-09 18:37:10 (GMT)
committerFred Drake <fdrake@acm.org>2002-08-09 18:37:10 (GMT)
commit56d12661934cfa280abf4884528d9e481a2d7a01 (patch)
tree709585342b4a852e213cf4a5a1521103651a8d35 /Lib
parent72bc456403106c66a551fe046f7355579e17066f (diff)
downloadcpython-56d12661934cfa280abf4884528d9e481a2d7a01.zip
cpython-56d12661934cfa280abf4884528d9e481a2d7a01.tar.gz
cpython-56d12661934cfa280abf4884528d9e481a2d7a01.tar.bz2
Add tests for weakref support for generator-iterators.
Part of fixing SF bug #591704.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_generators.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 170d92e..9078b55 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -1359,12 +1359,38 @@ Solution 2
+---+---+---+---+---+---+---+---+---+---+
"""
+weakref_tests = """\
+Generators are weakly referencable:
+
+>>> import weakref
+>>> def gen():
+... yield 'foo!'
+...
+>>> wr = weakref.ref(gen)
+>>> wr() is gen
+True
+>>> p = weakref.proxy(gen)
+
+Generator-iterators are weakly referencable as well:
+
+>>> gi = gen()
+>>> wr = weakref.ref(gi)
+>>> wr() is gi
+True
+>>> p = weakref.proxy(gi)
+>>> list(p)
+['foo!']
+
+"""
+
__test__ = {"tut": tutorial_tests,
"pep": pep_tests,
"email": email_tests,
"fun": fun_tests,
"syntax": syntax_tests,
- "conjoin": conjoin_tests}
+ "conjoin": conjoin_tests,
+ "weakref": weakref_tests,
+ }
# Magic test name that regrtest.py invokes *after* importing this module.
# This worms around a bootstrap problem.