Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(197)

Unified Diff: Lib/unittest/case.py

Issue 19817: tracemalloc add a memory limit feature
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/threading.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/unittest/case.py Wed Dec 04 01:47:46 2013 +0100
+++ b/Lib/unittest/case.py Wed Dec 04 02:02:18 2013 +0100
@@ -9,6 +9,8 @@ import re
import warnings
import collections
import contextlib
+import tracemalloc
+import random
from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
@@ -567,8 +569,13 @@ class TestCase(object):
self.setUp()
if outcome.success:
outcome.expecting_failure = expecting_failure
+ limit = random.randint(100, 1024*50)
with outcome.testPartExecutor(self, isTest=True):
- testMethod()
+ tracemalloc.start(memory_limit=limit)
+ try:
+ testMethod()
+ finally:
+ tracemalloc.stop()
outcome.expecting_failure = False
with outcome.testPartExecutor(self):
self.tearDown()
« no previous file with comments | « Lib/threading.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+