diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-02-16 19:52:01 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-02-16 19:52:01 (GMT) |
commit | cf626032763077bf959937705ed35f9e2b40a862 (patch) | |
tree | bed221f523db3a118706cc9bf1a451b6e0aebcae /Lib | |
parent | eb43736de2a746369dd42f406bc705ec413f2e72 (diff) | |
download | cpython-cf626032763077bf959937705ed35f9e2b40a862.zip cpython-cf626032763077bf959937705ed35f9e2b40a862.tar.gz cpython-cf626032763077bf959937705ed35f9e2b40a862.tar.bz2 |
backout fafac90b69c4
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/test/regrtest.py | 11 | ||||
-rw-r--r-- | Lib/test/test_pkgutil.py | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index ca4d820..ae62c6e 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -1318,10 +1318,9 @@ def dash_R(the_module, test, indirect_test, huntrleaks): try: import zipimport except ImportError: - zsc = zdc = None # Run unmodified on platforms without zipimport support + zdc = None # Run unmodified on platforms without zipimport support else: zdc = zipimport._zip_directory_cache.copy() - zsc = zipimport._zip_stat_cache.copy() abcs = {} for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]: if not isabstract(abc): @@ -1344,13 +1343,13 @@ def dash_R(the_module, test, indirect_test, huntrleaks): print("beginning", repcount, "repetitions", file=sys.stderr) print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr) sys.stderr.flush() - dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs) + dash_R_cleanup(fs, ps, pic, zdc, abcs) for i in range(repcount): rc_before = sys.gettotalrefcount() run_the_test() sys.stderr.write('.') sys.stderr.flush() - dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs) + dash_R_cleanup(fs, ps, pic, zdc, abcs) rc_after = sys.gettotalrefcount() if i >= nwarmup: deltas.append(rc_after - rc_before) @@ -1365,7 +1364,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks): return True return False -def dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs): +def dash_R_cleanup(fs, ps, pic, zdc, abcs): import gc, copyreg import _strptime, linecache import urllib.parse, urllib.request, mimetypes, doctest @@ -1391,8 +1390,6 @@ def dash_R_cleanup(fs, ps, pic, zdc, zsc, abcs): else: zipimport._zip_directory_cache.clear() zipimport._zip_directory_cache.update(zdc) - zipimport._zip_stat_cache.clear() - zipimport._zip_stat_cache.update(zsc) # clear type cache sys._clear_type_cache() diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index 0db4fc6..fd06614 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -338,6 +338,11 @@ class ImportlibMigrationTests(unittest.TestCase): def test_main(): run_unittest(PkgutilTests, PkgutilPEP302Tests, ExtendPathTests, NestedNamespacePackageTest, ImportlibMigrationTests) + # this is necessary if test is run repeated (like when finding leaks) + import zipimport + import importlib + zipimport._zip_directory_cache.clear() + importlib.invalidate_caches() if __name__ == '__main__': |