[Patches] regression test finalization

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Wed, 12 Apr 2000 06:22:09 +0200 (CEST)


Feature-specific modules keep being imported until the end of
the test suite. This increases unnecessarily the overall memory
consumption. This patch suggests a best effort per-test finalization
by unloading the newly imported modules after every test.

If not convinced in the usefulness of the patch, I can provide figures.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--
I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------  
*** Lib/test/regrtest.py-orig	Wed Apr 12 06:09:22 2000
--- Lib/test/regrtest.py	Wed Apr 12 06:08:38 2000
***************
*** 105,110 ****
--- 105,111 ----
      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,123 ****
--- 119,128 ----
                  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",