diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-12-01 22:31:51 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-12-01 22:31:51 -0500 |
commit | 0f07f434294885c615fe850af059f50419eb68c1 (patch) | |
tree | db921b747d294cbb4b37fbaadfe863df48783ccf | |
parent | d99b6663f627f1ca0df6a38d32c24d60a8dcfcc8 (diff) | |
download | python-coveragepy-0f07f434294885c615fe850af059f50419eb68c1.tar.gz |
An attempt to make the memory leak test more predictable, but it might be impossible.
-rw-r--r-- | test/test_oddball.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/test_oddball.py b/test/test_oddball.py index 0376f65..6c97272 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)) |