def test_exclusiveMapperOverrides(self): """ L{ExclusiveMapper} can be overriden. """ l = ["sys", "exocet.test"] d = {"sys": object()} em = ExclusiveMapper(pep302Mapper, l).withOverrides(d) self.assertEqual(em.lookup("sys"), d["sys"])
def test_exclusiveMapper(self): """ L{ExclusiveMapper} implements an effective blacklist. """ l = ["sys", "exocet.test"] em = ExclusiveMapper(pep302Mapper, l) verifyObject(IMapper, em) for name in l: self.assertRaises(ImportError, em.lookup, name) self.assertFalse(em.contains(name))
"asyncore", # Use Twisted's event loop. "ctypes", # Segfault protection. "gc", # Haha, no. "imp", # Haha, no. "inspect", # Haha, no. "multiprocessing", # Use Twisted's process interface. "socket", # Use Twisted's socket interface. "subprocess", # Use Twisted's process interface. "thread", # Use Twisted's thread interface. "threading", # Use Twisted's thread interface. ]) overrides = { "twisted.internet.reactor": reactor, "saxutils": saxutils, } bravoMapper = ExclusiveMapper(pep302Mapper, blacklisted).withOverrides(overrides) class PluginException(Exception): """ Signal an error encountered during plugin handling. """ def sort_plugins(plugins): """ Make a sorted list of plugins by dependency. If the list cannot be arranged into a DAG, an error will be raised. This usually means that a cyclic dependency was found.