コード例 #1
0
ファイル: test_exocet.py プロジェクト: reuben/bravo
 def test_overrides(self):
     """
     The L{pep302Mapper} supports overriding its mappings with a dict.
     """
     pep302Mapper._oldSysModules = sys.modules.copy()
     fakeMath = object()
     m = pep302Mapper.withOverrides({"math": fakeMath})
     self.assertTrue(m.contains("math"))
     self.assertTrue(m.contains("sys"))
     assertIdentical(self, m.lookup("math"), fakeMath)
     assertIdentical(self, m.lookup("sys"), sys)
コード例 #2
0
ファイル: test_exocet.py プロジェクト: MostAwesomeDude/hamper
 def test_overrides(self):
     """
     The L{pep302Mapper} supports overriding its mappings with a dict.
     """
     pep302Mapper._oldSysModules = sys.modules.copy()
     fakeMath = object()
     m = pep302Mapper.withOverrides({"math": fakeMath})
     self.assertTrue(m.contains("math"))
     self.assertTrue(m.contains("sys"))
     assertIdentical(self, m.lookup("math"), fakeMath)
     assertIdentical(self, m.lookup("sys"), sys)
コード例 #3
0
    def test_loadWithLocalImports(self):
        """
        Execution of local imports are resolved in the context the
        containing module was originally loaded in.
        """
        class fakeUtil:
            utilName = "booo"

        class tpli:
            util = fakeUtil
        m = pep302Mapper.withOverrides(
            {"exocet.test.testpackage_localimports": tpli})

        foo = loadNamed("exocet.test.testpackage_localimports.foo", m)
        self.assertEqual(foo.fooName, [])
        util2 = foo.do()
        self.assertEqual(foo.fooName[0], fakeUtil.utilName)
        self.assertEqual(util2.utilName, fakeUtil.utilName)