Skip to content

Commit 5796d26

Browse files
committed
Patch by Vladimir Marangozov to unload additionally imported modules
after each test has been run. This avoids excessive memory growth during the tests.
1 parent cdd092f commit 5796d26

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/regrtest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def main(tests=None, testdir=None):
105105
if single:
106106
tests = tests[:1]
107107
test_support.verbose = verbose # Tell tests to be moderately quiet
108+
save_modules = sys.modules.keys()
108109
for test in tests:
109110
if not quiet:
110111
print test
@@ -118,6 +119,10 @@ def main(tests=None, testdir=None):
118119
print "test", test,
119120
print "skipped -- an optional feature could not be imported"
120121
skipped.append(test)
122+
# Unload the newly imported modules (best effort finalization)
123+
for module in sys.modules.keys():
124+
if module not in save_modules:
125+
test_support.unload(module)
121126
if good and not quiet:
122127
if not bad and not skipped and len(good) > 1:
123128
print "All",

0 commit comments

Comments
 (0)