diff options
author | Thomas Wouters <thomas@python.org> | 2006-03-28 08:44:55 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-03-28 08:44:55 (GMT) |
commit | 4054b9720b31c9b2f06c840a96153fb3879ada7d (patch) | |
tree | af28c84225f0594e74771d837a1ebffe7030aca6 /Lib/test/test_generators.py | |
parent | a33b2bc873fd5b02e02c8961a32989c83066414e (diff) | |
download | cpython-4054b9720b31c9b2f06c840a96153fb3879ada7d.zip cpython-4054b9720b31c9b2f06c840a96153fb3879ada7d.tar.gz cpython-4054b9720b31c9b2f06c840a96153fb3879ada7d.tar.bz2 |
In true regression-test spirit, make sure the
itertools.tee->instance->attribute->itertools.tee and
itertools.tee->teedataobject->itertools.tee cycles, which can be found now
that itertools.tee and its teedataobject participate in GC, remain findable
and cleanable. The test won't fail when they aren't, but at least the
frequent hunt-refleaks runs would spot the rise in refleaks.
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r-- | Lib/test/test_generators.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 6b9b491..2df54df 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -1713,6 +1713,34 @@ enclosing function a generator: """ +refleaks_tests = """ +Prior to adding cycle-GC support to itertools.tee, this code would leak +references. We add it to the standard suite so the routine refleak-tests +would trigger if it starts being uncleanable again. + +>>> import itertools +>>> def leak(): +... class gen: +... def __iter__(self): +... return self +... def next(self): +... return self.item +... g = gen() +... head, tail = itertools.tee(g) +... g.item = head +... return head +>>> it = leak() + +Make sure to also test the involvement of the tee-internal teedataobject, +which stores returned items. + +>>> item = it.next() + +There should be more test_generator-induced refleaks here, after they get +fixed. + +""" + __test__ = {"tut": tutorial_tests, "pep": pep_tests, "email": email_tests, @@ -1721,6 +1749,7 @@ __test__ = {"tut": tutorial_tests, "conjoin": conjoin_tests, "weakref": weakref_tests, "coroutine": coroutine_tests, + "refleaks": refleaks_tests, } # Magic test name that regrtest.py invokes *after* importing this module. |