summaryrefslogtreecommitdiffstats
path: root/Lib/test/leakers
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-04-14 06:33:24 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-04-14 06:33:24 (GMT)
commit621292237c2d47dabb33b37ec6db945fa1d5716e (patch)
tree101b54855400c6a672a20fcf2b5f88354ae83f6a /Lib/test/leakers
parentcde87504145085dc371c74d755a5084de5dd9b64 (diff)
downloadcpython-621292237c2d47dabb33b37ec6db945fa1d5716e.zip
cpython-621292237c2d47dabb33b37ec6db945fa1d5716e.tar.gz
cpython-621292237c2d47dabb33b37ec6db945fa1d5716e.tar.bz2
Restore test tee with some modifications.
The test case came from test_generators, not test_itertools. Ensure there's no cyclic garbage we are counting. This is weird because it leaks, then reaches a limit: python.exe -i test_tee.py >>> leak() 0 [26633 refs] >>> leak() 0 [26658 refs] >>> leak() 0 [26683 refs] >>> leak() 0 [26708 refs] >>> leak() 0 [26708 refs] >>> leak() 0 [26708 refs] >>> leak() 0
Diffstat (limited to 'Lib/test/leakers')
-rw-r--r--Lib/test/leakers/test_tee.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/leakers/test_tee.py b/Lib/test/leakers/test_tee.py
new file mode 100644
index 0000000..f0aa444
--- /dev/null
+++ b/Lib/test/leakers/test_tee.py
@@ -0,0 +1,25 @@
+
+# Test case taken from test_generators
+# See http://mail.python.org/pipermail/python-dev/2005-November/058339.html
+
+from itertools import tee
+import gc
+
+def leak():
+ def inner():
+ def fib():
+ def yield_identity_forever(g):
+ while 1:
+ yield g
+ def _fib():
+ for i in yield_identity_forever(head):
+ yield i
+ head, tail, result = tee(_fib(), 3)
+ return result
+
+ x = fib()
+ x.next()
+ inner()
+ gc.collect() ; gc.collect()
+ # this is expected to return 0
+ return gc.collect()