]> granicus.if.org Git - python/commitdiff
Explicitly test relative imports by reusing importlib tests.
authorBrett Cannon <bcannon@gmail.com>
Fri, 23 Jul 2010 14:03:16 +0000 (14:03 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 23 Jul 2010 14:03:16 +0000 (14:03 +0000)
Closes issue 8392. Thanks Virgil Dupras for the initial patch.

Lib/test/test_import.py

index 929caa66e68910b8d180b65a6c38ee73ebd5fd20..be82b2223be6e34a43f709970f290a93c2e24edf 100644 (file)
@@ -1,6 +1,8 @@
 import builtins
 import errno
 import imp
+from importlib.test.import_ import test_relative_imports
+from importlib.test.import_ import util as importlib_util
 import marshal
 import os
 import py_compile
@@ -633,10 +635,21 @@ class PycacheTests(unittest.TestCase):
                          os.path.join(os.curdir, foo_pyc))
 
 
+class RelativeImportTests(test_relative_imports.RelativeImports):
+
+    def setUp(self):
+        self._importlib_util_flag = importlib_util.using___import__
+        importlib_util.using___import__ = True
+
+    def tearDown(self):
+        importlib_util.using___import__ = self._importlib_util_flag
+
+
 def test_main(verbose=None):
     run_unittest(ImportTests, PycacheTests,
                  PycRewritingTests, PathsTests, RelativeImportTests,
-                 OverridingImportBuiltinTests)
+                 OverridingImportBuiltinTests,
+                 RelativeImportTests)
 
 
 if __name__ == '__main__':