Skip to content

Commit

Permalink
Add tests for weakref support for generator-iterators.
Browse files Browse the repository at this point in the history
Part of fixing SF bug #591704.
  • Loading branch information
freddrake committed Aug 9, 2002
1 parent 72bc456 commit 56d1266
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,12 +1359,38 @@ def printsolution(self, x):
+---+---+---+---+---+---+---+---+---+---+
"""

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.
Expand Down

0 comments on commit 56d1266

Please sign in to comment.