summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-12-01 22:31:51 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-12-01 22:31:51 -0500
commitff5e462bfd85b19a8faef3b25647996f08daaf04 (patch)
treecf79e7be946d5ecb39503f95c7b15590fa4afad6
parent9b15c8db1b78e0b1c1c45332167a1cf7579b50f7 (diff)
downloadpython-coveragepy-git-ff5e462bfd85b19a8faef3b25647996f08daaf04.tar.gz
An attempt to make the memory leak test more predictable, but it might be impossible.
-rw-r--r--test/test_oddball.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/test_oddball.py b/test/test_oddball.py
index 0376f65a..6c97272d 100644
--- a/test/test_oddball.py
+++ b/test/test_oddball.py
@@ -68,9 +68,8 @@ class MemoryLeakTest(CoverageTest):
def test_for_leaks(self):
lines = list(range(301, 315))
lines.remove(306)
- baseline_ram = osinfo.process_ram()
# Ugly string mumbo jumbo to get 300 blank lines at the beginning..
- self.check_coverage("""\
+ code = """\
# blank line\n""" * 300 + """\
def once(x):
if x % 100 == 0:
@@ -80,15 +79,19 @@ class MemoryLeakTest(CoverageTest):
else:
return 11
i = 0 # Portable loop without alloc'ing memory.
- while i < 10000:
+ while i < ITERS:
try:
once(i)
except:
pass
i += 1
- """,
- lines, "")
- ram_growth = osinfo.process_ram() - baseline_ram
+ """
+ ram_0 = osinfo.process_ram()
+ self.check_coverage(code.replace("ITERS", "10"), lines, "")
+ ram_1 = osinfo.process_ram()
+ self.check_coverage(code.replace("ITERS", "10000"), lines, "")
+ ram_2 = osinfo.process_ram()
+ ram_growth = (ram_2 - ram_1) - (ram_1 - ram_0)
self.assert_(ram_growth < 100000, "RAM grew by %d" % (ram_growth))