]> granicus.if.org Git - python/commitdiff
Patch by Vladimir Marangozov to unload additionally imported modules
authorGuido van Rossum <guido@python.org>
Fri, 21 Apr 2000 21:35:06 +0000 (21:35 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 21 Apr 2000 21:35:06 +0000 (21:35 +0000)
after each test has been run.  This avoids excessive memory growth
during the tests.

Lib/test/regrtest.py

index 6364d7179c36a65296550f6ea5603ec59fe3318b..924890ab76f13d51c92692f5972675d01279ed06 100755 (executable)
@@ -105,6 +105,7 @@ def main(tests=None, testdir=None):
     if single:
         tests = tests[:1]
     test_support.verbose = verbose      # Tell tests to be moderately quiet
+    save_modules = sys.modules.keys()
     for test in tests:
         if not quiet:
             print test
@@ -118,6 +119,10 @@ def main(tests=None, testdir=None):
                 print "test", test,
                 print "skipped -- an optional feature could not be imported"
             skipped.append(test)
+        # Unload the newly imported modules (best effort finalization)
+        for module in sys.modules.keys():
+            if module not in save_modules:
+                test_support.unload(module)
     if good and not quiet:
         if not bad and not skipped and len(good) > 1:
             print "All",