summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-07-20 23:21:49 (GMT)
committerGeorg Brandl <georg@python.org>2008-07-20 23:21:49 (GMT)
commitd68442dc933854dab7c942f9f343764235baf822 (patch)
treef894177b620b13dbba130809f50b29c5d10abb75
parentaac8fd3153179875f423dee305aa32df054aaad0 (diff)
downloadcpython-d68442dc933854dab7c942f9f343764235baf822.zip
cpython-d68442dc933854dab7c942f9f343764235baf822.tar.gz
cpython-d68442dc933854dab7c942f9f343764235baf822.tar.bz2
Merged revisions 65163 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65163 | georg.brandl | 2008-07-21 01:18:55 +0200 (Mon, 21 Jul 2008) | 4 lines Save the whole of sys.modules instead of using an import tracker. This, when merged to py3k, will fix the spurious buildbot failure in test_urllib2 ("<urlopen error unknown url type: do>"). ........
-rw-r--r--Lib/test/test_importhooks.py25
1 files changed, 4 insertions, 21 deletions
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index acf45fb..f267f79 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -33,15 +33,6 @@ test2_futrel_co = compile(futimp + relimp + test_src, "<???>", "exec")
test_path = "!!!_test_!!!"
-class ImportTracker:
- """Importer that only tracks attempted imports."""
- def __init__(self):
- self.imports = []
- def find_module(self, fullname, path=None):
- self.imports.append(fullname)
- return None
-
-
class TestImporter:
modules = {
@@ -152,17 +143,15 @@ class ImportHooksBaseTestCase(unittest.TestCase):
self.meta_path = sys.meta_path[:]
self.path_hooks = sys.path_hooks[:]
sys.path_importer_cache.clear()
- self.tracker = ImportTracker()
- sys.meta_path.insert(0, self.tracker)
+ self.modules_before = sys.modules.copy()
def tearDown(self):
sys.path[:] = self.path
sys.meta_path[:] = self.meta_path
sys.path_hooks[:] = self.path_hooks
sys.path_importer_cache.clear()
- for fullname in self.tracker.imports:
- if fullname in sys.modules:
- del sys.modules[fullname]
+ sys.modules.clear()
+ sys.modules.update(self.modules_before)
class ImportHooksTestCase(ImportHooksBaseTestCase):
@@ -256,13 +245,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
for mname in mnames:
m = __import__(mname, globals(), locals(), ["__dummy__"])
m.__loader__ # to make sure we actually handled the import
-## # Delete urllib from modules because urlparse was imported above.
-## # Without this hack, test_socket_ssl fails if run in this order:
-## # regrtest.py test_codecmaps_tw test_importhooks test_socket_ssl
-## try:
-## del sys.modules['urllib']
-## except KeyError:
-## pass
+
def test_main():
support.run_unittest(ImportHooksTestCase)