diff options
Diffstat (limited to 'Lib/test')
-rwxr-xr-x | Lib/test/regrtest.py | 24 | ||||
-rw-r--r-- | Lib/test/support.py | 3 | ||||
-rw-r--r-- | Lib/test/test_minidom.py | 2 |
3 files changed, 26 insertions, 3 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index e46f935..59bdb01 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -173,6 +173,7 @@ import io import json import logging import os +import packaging.database import platform import random import re @@ -967,6 +968,7 @@ class saved_test_environment: 'sys.warnoptions', 'threading._dangling', 'multiprocessing.process._dangling', 'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES', + 'packaging.database_caches', ) def get_sys_argv(self): @@ -1054,6 +1056,28 @@ class saved_test_environment: # Can't easily revert the logging state pass + def get_packaging_database_caches(self): + # caching system used by the PEP 376 implementation + # we have one boolean and four dictionaries, initially empty + switch = packaging.database._cache_enabled + saved = [] + for name in ('_cache_name', '_cache_name_egg', + '_cache_path', '_cache_path_egg'): + cache = getattr(packaging.database, name) + saved.append((id(cache), cache, cache.copy())) + return switch, saved + def restore_packaging_database_caches(self, saved): + switch, saved_caches = saved + packaging.database._cache_enabled = switch + for offset, name in enumerate(('_cache_name', '_cache_name_egg', + '_cache_path', '_cache_path_egg')): + _, cache, items = saved_caches[offset] + # put back the same object in place + setattr(packaging.database, name, cache) + # now restore its items + cache.clear() + cache.update(items) + def get_sys_warnoptions(self): return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:] def restore_sys_warnoptions(self, saved_options): diff --git a/Lib/test/support.py b/Lib/test/support.py index 619bf4c..556e82f4 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -187,8 +187,7 @@ def get_attribute(obj, name): try: attribute = getattr(obj, name) except AttributeError: - raise unittest.SkipTest("module %s has no attribute %s" % ( - repr(obj), name)) + raise unittest.SkipTest("object %r has no attribute %r" % (obj, name)) else: return attribute diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 0a60136..2621f72 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -467,7 +467,7 @@ class MinidomTest(unittest.TestCase): dom.unlink() self.confirm(domstr == str.replace("\n", "\r\n")) - def test_toPrettyXML_perserves_content_of_text_node(self): + def test_toprettyxml_preserves_content_of_text_node(self): str = '<A>B</A>' dom = parseString(str) dom2 = parseString(dom.toprettyxml()) |