summaryrefslogtreecommitdiff
path: root/Lib/test/leakers
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-02-28 19:02:05 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2006-02-28 19:02:05 +0000
commitedc8f1366af2d32882649647a7a79873a6cb9503 (patch)
treeaa51d64976c2f4f987fe7b631e1cc1a47e1fce70 /Lib/test/leakers
parent99b4ee637322a9e3705a316008f9fc68eefceb02 (diff)
downloadcpython-git-edc8f1366af2d32882649647a7a79873a6cb9503.tar.gz
Add directory which contains known ref leaks. Some of these are likely to be system dependent (like test_gestalt).
Diffstat (limited to 'Lib/test/leakers')
-rw-r--r--Lib/test/leakers/README18
-rw-r--r--Lib/test/leakers/__init__.py0
-rw-r--r--Lib/test/leakers/test_gestalt.py15
-rw-r--r--Lib/test/leakers/test_tee.py19
4 files changed, 52 insertions, 0 deletions
diff --git a/Lib/test/leakers/README b/Lib/test/leakers/README
new file mode 100644
index 0000000000..801ed9577a
--- /dev/null
+++ b/Lib/test/leakers/README
@@ -0,0 +1,18 @@
+This directory contains test cases that are known to leak references.
+The idea is that you can import these modules while in the interpreter
+and call the leak function repeatedly. This will only be helpful if
+the interpreter was built in debug mode. If the total ref count
+doesn't increase, the bug has been fixed.
+
+Here's an example interpreter session for test_gestalt which still leaks:
+
+>>> from test.leakers.test_gestalt import leak
+[24275 refs]
+>>> leak()
+[28936 refs]
+>>> leak()
+[28938 refs]
+>>> leak()
+[28940 refs]
+>>>
+
diff --git a/Lib/test/leakers/__init__.py b/Lib/test/leakers/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/Lib/test/leakers/__init__.py
diff --git a/Lib/test/leakers/test_gestalt.py b/Lib/test/leakers/test_gestalt.py
new file mode 100644
index 0000000000..f947fc516f
--- /dev/null
+++ b/Lib/test/leakers/test_gestalt.py
@@ -0,0 +1,15 @@
+
+import sys
+
+if sys.platform != 'darwin':
+ raise ValueError, "This test only leaks on Mac OS X'
+
+def leak():
+ # taken from platform._mac_ver_lookup()
+ from gestalt import gestalt
+ import MacOS
+
+ try:
+ gestalt('sysu')
+ except MacOS.Error:
+ pass
diff --git a/Lib/test/leakers/test_tee.py b/Lib/test/leakers/test_tee.py
new file mode 100644
index 0000000000..4ce24cae30
--- /dev/null
+++ b/Lib/test/leakers/test_tee.py
@@ -0,0 +1,19 @@
+
+# Test case taken from test_itertools
+# See http://mail.python.org/pipermail/python-dev/2005-November/058339.html
+
+from itertools import tee
+
+def leak():
+ 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()