]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_modulefinder.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_modulefinder.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_modulefinder.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_modulefinder.py
deleted file mode 100644 (file)
index 6470283..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-import __future__\r
-import os\r
-import unittest\r
-import distutils.dir_util\r
-import tempfile\r
-\r
-from test import test_support\r
-\r
-try: set\r
-except NameError: from sets import Set as set\r
-\r
-import modulefinder\r
-\r
-# Note: To test modulefinder with Python 2.2, sets.py and\r
-# modulefinder.py must be available - they are not in the standard\r
-# library.\r
-\r
-TEST_DIR = tempfile.mkdtemp()\r
-TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)]\r
-\r
-# Each test description is a list of 5 items:\r
-#\r
-# 1. a module name that will be imported by modulefinder\r
-# 2. a list of module names that modulefinder is required to find\r
-# 3. a list of module names that modulefinder should complain\r
-#    about because they are not found\r
-# 4. a list of module names that modulefinder should complain\r
-#    about because they MAY be not found\r
-# 5. a string specifying packages to create; the format is obvious imo.\r
-#\r
-# Each package will be created in TEST_DIR, and TEST_DIR will be\r
-# removed after the tests again.\r
-# Modulefinder searches in a path that contains TEST_DIR, plus\r
-# the standard Lib directory.\r
-\r
-maybe_test = [\r
-    "a.module",\r
-    ["a", "a.module", "sys",\r
-     "b"],\r
-    ["c"], ["b.something"],\r
-    """\\r
-a/__init__.py\r
-a/module.py\r
-                                from b import something\r
-                                from c import something\r
-b/__init__.py\r
-                                from sys import *\r
-"""]\r
-\r
-maybe_test_new = [\r
-    "a.module",\r
-    ["a", "a.module", "sys",\r
-     "b", "__future__"],\r
-    ["c"], ["b.something"],\r
-    """\\r
-a/__init__.py\r
-a/module.py\r
-                                from b import something\r
-                                from c import something\r
-b/__init__.py\r
-                                from __future__ import absolute_import\r
-                                from sys import *\r
-"""]\r
-\r
-package_test = [\r
-    "a.module",\r
-    ["a", "a.b", "a.c", "a.module", "mymodule", "sys"],\r
-    ["blahblah"], [],\r
-    """\\r
-mymodule.py\r
-a/__init__.py\r
-                                import blahblah\r
-                                from a import b\r
-                                import c\r
-a/module.py\r
-                                import sys\r
-                                from a import b as x\r
-                                from a.c import sillyname\r
-a/b.py\r
-a/c.py\r
-                                from a.module import x\r
-                                import mymodule as sillyname\r
-                                from sys import version_info\r
-"""]\r
-\r
-absolute_import_test = [\r
-    "a.module",\r
-    ["a", "a.module",\r
-     "b", "b.x", "b.y", "b.z",\r
-     "__future__", "sys", "exceptions"],\r
-    ["blahblah"], [],\r
-    """\\r
-mymodule.py\r
-a/__init__.py\r
-a/module.py\r
-                                from __future__ import absolute_import\r
-                                import sys # sys\r
-                                import blahblah # fails\r
-                                import exceptions # exceptions\r
-                                import b.x # b.x\r
-                                from b import y # b.y\r
-                                from b.z import * # b.z.*\r
-a/exceptions.py\r
-a/sys.py\r
-                                import mymodule\r
-a/b/__init__.py\r
-a/b/x.py\r
-a/b/y.py\r
-a/b/z.py\r
-b/__init__.py\r
-                                import z\r
-b/unused.py\r
-b/x.py\r
-b/y.py\r
-b/z.py\r
-"""]\r
-\r
-relative_import_test = [\r
-    "a.module",\r
-    ["__future__",\r
-     "a", "a.module",\r
-     "a.b", "a.b.y", "a.b.z",\r
-     "a.b.c", "a.b.c.moduleC",\r
-     "a.b.c.d", "a.b.c.e",\r
-     "a.b.x",\r
-     "exceptions"],\r
-    [], [],\r
-    """\\r
-mymodule.py\r
-a/__init__.py\r
-                                from .b import y, z # a.b.y, a.b.z\r
-a/module.py\r
-                                from __future__ import absolute_import # __future__\r
-                                import exceptions # exceptions\r
-a/exceptions.py\r
-a/sys.py\r
-a/b/__init__.py\r
-                                from ..b import x # a.b.x\r
-                                #from a.b.c import moduleC\r
-                                from .c import moduleC # a.b.moduleC\r
-a/b/x.py\r
-a/b/y.py\r
-a/b/z.py\r
-a/b/g.py\r
-a/b/c/__init__.py\r
-                                from ..c import e # a.b.c.e\r
-a/b/c/moduleC.py\r
-                                from ..c import d # a.b.c.d\r
-a/b/c/d.py\r
-a/b/c/e.py\r
-a/b/c/x.py\r
-"""]\r
-\r
-relative_import_test_2 = [\r
-    "a.module",\r
-    ["a", "a.module",\r
-     "a.sys",\r
-     "a.b", "a.b.y", "a.b.z",\r
-     "a.b.c", "a.b.c.d",\r
-     "a.b.c.e",\r
-     "a.b.c.moduleC",\r
-     "a.b.c.f",\r
-     "a.b.x",\r
-     "a.another"],\r
-    [], [],\r
-    """\\r
-mymodule.py\r
-a/__init__.py\r
-                                from . import sys # a.sys\r
-a/another.py\r
-a/module.py\r
-                                from .b import y, z # a.b.y, a.b.z\r
-a/exceptions.py\r
-a/sys.py\r
-a/b/__init__.py\r
-                                from .c import moduleC # a.b.c.moduleC\r
-                                from .c import d # a.b.c.d\r
-a/b/x.py\r
-a/b/y.py\r
-a/b/z.py\r
-a/b/c/__init__.py\r
-                                from . import e # a.b.c.e\r
-a/b/c/moduleC.py\r
-                                #\r
-                                from . import f   # a.b.c.f\r
-                                from .. import x  # a.b.x\r
-                                from ... import another # a.another\r
-a/b/c/d.py\r
-a/b/c/e.py\r
-a/b/c/f.py\r
-"""]\r
-\r
-relative_import_test_3 = [\r
-    "a.module",\r
-    ["a", "a.module"],\r
-    ["a.bar"],\r
-    [],\r
-    """\\r
-a/__init__.py\r
-                                def foo(): pass\r
-a/module.py\r
-                                from . import foo\r
-                                from . import bar\r
-"""]\r
-\r
-def open_file(path):\r
-    ##print "#", os.path.abspath(path)\r
-    dirname = os.path.dirname(path)\r
-    distutils.dir_util.mkpath(dirname)\r
-    return open(path, "w")\r
-\r
-def create_package(source):\r
-    ofi = None\r
-    try:\r
-        for line in source.splitlines():\r
-            if line.startswith(" ") or line.startswith("\t"):\r
-                ofi.write(line.strip() + "\n")\r
-            else:\r
-                if ofi:\r
-                    ofi.close()\r
-                ofi = open_file(os.path.join(TEST_DIR, line.strip()))\r
-    finally:\r
-        if ofi:\r
-            ofi.close()\r
-\r
-class ModuleFinderTest(unittest.TestCase):\r
-    def _do_test(self, info, report=False):\r
-        import_this, modules, missing, maybe_missing, source = info\r
-        create_package(source)\r
-        try:\r
-            mf = modulefinder.ModuleFinder(path=TEST_PATH)\r
-            mf.import_hook(import_this)\r
-            if report:\r
-                mf.report()\r
-##                # This wouldn't work in general when executed several times:\r
-##                opath = sys.path[:]\r
-##                sys.path = TEST_PATH\r
-##                try:\r
-##                    __import__(import_this)\r
-##                except:\r
-##                    import traceback; traceback.print_exc()\r
-##                sys.path = opath\r
-##                return\r
-            modules = set(modules)\r
-            found = set(mf.modules.keys())\r
-            more = list(found - modules)\r
-            less = list(modules - found)\r
-            # check if we found what we expected, not more, not less\r
-            self.assertEqual((more, less), ([], []))\r
-\r
-            # check for missing and maybe missing modules\r
-            bad, maybe = mf.any_missing_maybe()\r
-            self.assertEqual(bad, missing)\r
-            self.assertEqual(maybe, maybe_missing)\r
-        finally:\r
-            distutils.dir_util.remove_tree(TEST_DIR)\r
-\r
-    def test_package(self):\r
-        self._do_test(package_test)\r
-\r
-    def test_maybe(self):\r
-        self._do_test(maybe_test)\r
-\r
-    if getattr(__future__, "absolute_import", None):\r
-\r
-        def test_maybe_new(self):\r
-            self._do_test(maybe_test_new)\r
-\r
-        def test_absolute_imports(self):\r
-            self._do_test(absolute_import_test)\r
-\r
-        def test_relative_imports(self):\r
-            self._do_test(relative_import_test)\r
-\r
-        def test_relative_imports_2(self):\r
-            self._do_test(relative_import_test_2)\r
-\r
-        def test_relative_imports_3(self):\r
-            self._do_test(relative_import_test_3)\r
-\r
-def test_main():\r
-    distutils.log.set_threshold(distutils.log.WARN)\r
-    test_support.run_unittest(ModuleFinderTest)\r
-\r
-if __name__ == "__main__":\r
-    unittest.main()\r