def test_loadWithLocalImports(self): """ Execution of local imports are resolved in the context the containing module was originally loaded in. """ pc = loadPackageNamed("exocet.test.testpackage_localimports", emptyMapper) foo = pc.loadNamed("exocet.test.testpackage_localimports.foo") util = pc.loadNamed("exocet.test.testpackage_localimports.util") self.assertEqual(foo.fooName, []) util2 = foo.do() self.assertEqual(foo.fooName[0], util.utilName) assertIdentical(self, util2, util)
def test_loadCircularPackage(self): """ Packages with circular imports can be loaded correctly by C{loadPackageNamed}. """ pc = loadPackageNamed("exocet.test.testpackage", emptyMapper) top = pc.loadNamed("exocet.test.testpackage.topmodule") foo = pc.loadNamed("exocet.test.testpackage.foo") baz = pc.loadNamed("exocet.test.testpackage.baz") util = pc.loadNamed("exocet.test.testpackage.util") assertIdentical(self, top.foo, foo) assertIdentical(self, top.baz, baz) assertIdentical(self, foo.util, baz.util)
def test_loadPackageNamed(self): """ Calling C{loadPackageNamed} returns a package context from which modules with shared state and knowledge of other code in the package can be loaded. """ pc = loadPackageNamed("exocet.test.testpackage", emptyMapper) top = pc.loadNamed("exocet.test.testpackage.topmodule") foo = pc.loadNamed("exocet.test.testpackage.foo") baz = pc.loadNamed("exocet.test.testpackage.baz") util = pc.loadNamed("exocet.test.testpackage.util") assertIdentical(self, top.foo, foo) assertIdentical(self, top.baz, baz) assertIdentical(self, foo.util, baz.util)