Example #1
0
class ImportHooksLookupTests(unittest.TestCase, LookupsTestCase):
    """
    Tests for lookup methods in the presence of L{ihooks}-style import hooks.
    Runs all of the tests from L{LookupsTestCase} after installing a custom
    import hook.
    """
    skip = ("ihooks support is broken, and has probably been broken since "
            "Python 2.6. On the other hand, no one should use ihooks.")


    def setUp(self):
        """
        Perturb the normal import behavior subtly by installing an import
        hook.  No custom behavior is provided, but this adds some extra
        frames to the call stack, which L{namedAny} must be able to account
        for.
        """
        self.importer = ModuleImporter()
        self.importer.install()


    def tearDown(self):
        """
        Uninstall the custom import hook.
        """
        self.importer.uninstall()
Example #2
0
class ImportHooksLookupTests(LookupsTestCase):
    """
    Tests for lookup methods in the presence of L{ihooks}-style import hooks.
    Runs all of the tests from L{LookupsTestCase} after installing a custom
    import hook.
    """
    if ModuleImporter == None:
        skip = "ihooks not available"

    def setUp(self):
        """
        Perturb the normal import behavior subtly by installing an import
        hook.  No custom behavior is provided, but this adds some extra
        frames to the call stack, which L{namedAny} must be able to account
        for.
        """
        self.importer = ModuleImporter()
        self.importer.install()


    def tearDown(self):
        """
        Uninstall the custom import hook.
        """
        self.importer.uninstall()
Example #3
0
    def install(self):
	if not sys.modules.has_key(''):
	    sys.modules[''] = package = imp.new_module('')
	    package.__path__ = None
	    self.loader.init_package(package)
	    for m in sys.modules.values():
		if not m: continue
		if not hasattr(m, '__'):
		    self.loader.set_parent(m)
	ModuleImporter.install(self)
Example #4
0
 def install(self):
     if not sys.modules.has_key(''):
         sys.modules[''] = package = imp.new_module('')
         package.__path__ = None
         self.loader.init_package(package)
         for m in sys.modules.values():
             if not m: continue
             if not hasattr(m, '__'):
                 self.loader.set_parent(m)
     ModuleImporter.install(self)
Example #5
0
"""New import scheme with package support.
Example #6
0
"""New import scheme with package support.