diff options
author | Guido van Rossum <guido@python.org> | 2007-11-22 00:55:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-11-22 00:55:51 (GMT) |
commit | 64c06e327d48150fc548cf18a4a7ae0b890e69fa (patch) | |
tree | daf53ab57c369a3d92c5a9deafc41df2ccd96127 /Lib/test/regrtest.py | |
parent | cc7f26bf207ee17e2c1b3e6545e145942aff612d (diff) | |
download | cpython-64c06e327d48150fc548cf18a4a7ae0b890e69fa.zip cpython-64c06e327d48150fc548cf18a4a7ae0b890e69fa.tar.gz cpython-64c06e327d48150fc548cf18a4a7ae0b890e69fa.tar.bz2 |
Backport of _abccoll.py by Benjamin Arangueren, issue 1383.
With some changes of my own thrown in (e.g. backport of r58107).
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-x | Lib/test/regrtest.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 7973b23..9694e2a 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -648,7 +648,7 @@ def cleanup_test_droppings(testname, verbose): def dash_R(the_module, test, indirect_test, huntrleaks): # This code is hackish and inelegant, but it seems to do the job. - import copy_reg + import copy_reg, _abcoll if not hasattr(sys, 'gettotalrefcount'): raise Exception("Tracking reference leaks requires a debug build " @@ -658,6 +658,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks): fs = warnings.filters[:] ps = copy_reg.dispatch_table.copy() pic = sys.path_importer_cache.copy() + abcs = {} + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: + for obj in abc.__subclasses__() + [abc]: + abcs[obj] = obj._abc_registry.copy() + + print >> sys.stderr, abcs if indirect_test: def run_the_test(): @@ -671,12 +677,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks): repcount = nwarmup + ntracked print >> sys.stderr, "beginning", repcount, "repetitions" print >> sys.stderr, ("1234567890"*(repcount//10 + 1))[:repcount] - dash_R_cleanup(fs, ps, pic) + dash_R_cleanup(fs, ps, pic, abcs) for i in range(repcount): rc = sys.gettotalrefcount() run_the_test() sys.stderr.write('.') - dash_R_cleanup(fs, ps, pic) + dash_R_cleanup(fs, ps, pic, abcs) if i >= nwarmup: deltas.append(sys.gettotalrefcount() - rc - 2) print >> sys.stderr @@ -687,11 +693,11 @@ def dash_R(the_module, test, indirect_test, huntrleaks): print >> refrep, msg refrep.close() -def dash_R_cleanup(fs, ps, pic): +def dash_R_cleanup(fs, ps, pic, abcs): import gc, copy_reg import _strptime, linecache, dircache import urlparse, urllib, urllib2, mimetypes, doctest - import struct, filecmp + import struct, filecmp, _abcoll from distutils.dir_util import _path_created # Restore some original values. @@ -701,6 +707,13 @@ def dash_R_cleanup(fs, ps, pic): sys.path_importer_cache.clear() sys.path_importer_cache.update(pic) + # Clear ABC registries, restoring previously saved ABC registries. + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: + for obj in abc.__subclasses__() + [abc]: + obj._abc_registry = abcs.get(obj, {}).copy() + obj._abc_cache.clear() + obj._abc_negative_cache.clear() + # Clear assorted module caches. _path_created.clear() re.purge() |