[pypy-svn] r55405 - pypy/dist/pypy/module/__builtin__/test

fijal at codespeak.net fijal at codespeak.net
Thu May 29 19:16:54 CEST 2008


Author: fijal
Date: Thu May 29 19:16:53 2008
New Revision: 55405

Modified:
   pypy/dist/pypy/module/__builtin__/test/test_import.py
Log:
A test for 55401


Modified: pypy/dist/pypy/module/__builtin__/test/test_import.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_import.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_import.py	Thu May 29 19:16:53 2008
@@ -536,3 +536,32 @@
             tried_imports[0][0] == "datetime"
         finally:
             sys.meta_path.pop()
+
+    def test_path_hooks_leaking(self):
+        class Importer(object):
+            def find_module(self, fullname, path=None):
+                if fullname == "a":
+                    return self
+
+            def load_module(self, name):
+                return sys
+        
+        def importer_for_path(path):
+            if path == "xxx":
+                return Importer()
+            raise ImportError()
+        import sys
+        try:
+            sys.path_hooks.append(importer_for_path)
+            sys.path.insert(0, "yyy")
+            sys.path.insert(0, "xxx")
+            import a
+            try:
+                import b
+            except ImportError:
+                pass
+            assert sys.path_importer_cache['yyy'] is None
+        finally:
+            sys.path.pop(0)
+            sys.path.pop(0)
+            sys.path_hooks.pop()



More information about the Pypy-commit mailing list