示例#1
0
 def test_encodings(self):
     from encodings import big5
     mf = ModuleFinder()
     mf.import_hook("encodings", None, ["big5"])
     mf.import_hook("encodings", None, ["codecs"])
     mf.import_hook("encodings", None, ["foo"])
     self.assertIn("encodings.big5", mf.modules)
     self.assertEqual({"encodings.foo"}, mf.missing())
示例#2
0
 def test_os_path(self):
     mf = ModuleFinder()
     mf.import_hook("os", None, ["path"])
     self.assertIn("os", mf.modules)
     self.assertIn("ntpath", mf.modules)
     self.assertNotIn("os.path", mf.missing())
     self.assertIn("posix", mf.missing())
     self.assertIn("fcntl", mf.missing())
     self.assertIn("os2", mf.missing())
示例#3
0
 def test_modulefinder(self):
     mf = ModuleFinder(path=sys.path)
     mf.import_hook("nested.test_tools")
     found = mf.modules.keys()
     try:
         self.assertEqual(set(found), self.modules)
         self.assertEqual(mf.missing(), self.missing)
     except AssertionError:
         mf.report()
         raise
示例#4
0
 def test_modulefinder(self):
     mf = ModuleFinder(path=sys.path)
     mf.import_hook("testmods.test_tools")
     found = mf.modules.keys()
     self.assertEqual(set(found), self.modules)
     self.assertEqual(mf.missing(), self.missing)
示例#5
0
    def test_collections_abc(self):
        from collections import abc
        import collections.abc
        from collections import namedtuple
        with self.assertRaises(ImportError):
            import collections.namedtuple

        mf = ModuleFinder()
        mf.import_hook("collections.abc")
        mf.import_hook("collections", None, ["namedtuple"])

        self.assertIn("collections.abc", mf.modules)
        self.assertNotIn("collections.namedtuple", mf.missing())

        mf = ModuleFinder()
        mf.import_hook("collections", None, ["abc"])

        self.assertIn("collections.abc", mf.modules)
        self.assertNotIn("collections.namedtuple", mf.missing())
示例#6
0
    def test_sys2(self):
        mf = ModuleFinder()
##        # This raises ImportError:
        mf.import_hook("os.path")
        self.assertNotIn("os.path", mf.missing())
        self.assertIn("posix", mf.missing())
示例#7
0
 def test_sys(self):
     mf = ModuleFinder(excludes=["posix"])
     mf.import_hook("os", None, ["path"])
     mf.import_hook("sys", None, ["spam"])
     self.assertNotIn("os.path", mf.missing())
     self.assertNotIn("posix", mf.missing())