Example #1
0
    def test_axiomaticCommandProvides(self):
        """
        Test that AxiomaticCommand itself does not provide IAxiomaticCommand or
        IPlugin, but subclasses do.
        """
        self.failIf(IAxiomaticCommand.providedBy(axiomatic.AxiomaticCommand), 'IAxiomaticCommand provided')
        self.failIf(IPlugin.providedBy(axiomatic.AxiomaticCommand), 'IPlugin provided')

        class _TestSubClass(axiomatic.AxiomaticCommand):
            pass

        self.failUnless(IAxiomaticCommand.providedBy(_TestSubClass), 'IAxiomaticCommand not provided')
        self.failUnless(IPlugin.providedBy(_TestSubClass), 'IPlugin not provided')
Example #2
0
    def test_axiomaticCommandProvides(self):
        """
        Test that AxiomaticCommand itself does not provide IAxiomaticCommand or
        IPlugin, but subclasses do.
        """
        self.failIf(IAxiomaticCommand.providedBy(axiomatic.AxiomaticCommand), 'IAxiomaticCommand provided')
        self.failIf(IPlugin.providedBy(axiomatic.AxiomaticCommand), 'IPlugin provided')

        class _TestSubClass(axiomatic.AxiomaticCommand):
            pass

        self.failUnless(IAxiomaticCommand.providedBy(_TestSubClass), 'IAxiomaticCommand not provided')
        self.failUnless(IPlugin.providedBy(_TestSubClass), 'IPlugin not provided')
Example #3
0
def get_plugins(interface, package):
    """
    Lazily find objects in a package which implement a given interface.

    The objects must also implement ``twisted.plugin.IPlugin``.

    This is a rewrite of Twisted's ``twisted.plugin.getPlugins`` which uses
    Exocet instead of Twisted to find the plugins.

    :param interface interface: the interface to match against
    :param str package: the name of the package to search
    """

    p = getModule(package)
    for pm in p.iterModules():
        try:
            m = load(pm, bravoMapper)
            for obj in vars(m).itervalues():
                try:
                    adapted = IPlugin(obj, None)
                    adapted = interface(adapted, None)
                except:
                    log.err()
                else:
                    if adapted is not None:
                        yield adapted
        except ImportError, ie:
            log.msg(ie)
Example #4
0
 def test_providesInterfaces(self):
     """
     Verify that the necessary interfaces for the object to be found as a
     twistd subcommand plugin are provided.
     """
     self.failUnless(IPlugin.providedBy(widgetServiceMaker))
     self.failUnless(IServiceMaker.providedBy(widgetServiceMaker))
Example #5
0
 def test_plugin(self):
     """
     :obj:`twisted.plugins.mimic.mimicService` is a twistd plugin
     referencing `mimic.tap.makeService`.
     """
     self.assertTrue(IPlugin.providedBy(mimicService))
     self.assertTrue(IServiceMaker.providedBy(mimicService))
     self.assertIs(mimicService.makeService, makeService)
Example #6
0
 def test_plugin(self):
     """
     :obj:`twisted.plugins.mimic.mimicService` is a twistd plugin
     referencing `mimic.tap.makeService`.
     """
     self.assertTrue(IPlugin.providedBy(mimicService))
     self.assertTrue(IServiceMaker.providedBy(mimicService))
     self.assertIs(mimicService.makeService, makeService)
Example #7
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventWriter))
     self.assertTrue(IPlugin.implementedBy(EventWriter))
     self.assertTrue(IHasOptions.implementedBy(EventWriter))
Example #8
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventPrinter))
     self.assertTrue(IPlugin.implementedBy(EventPrinter))
Example #9
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventWriter))
     self.assertTrue(IPlugin.implementedBy(EventWriter))
     self.assertTrue(IHasOptions.implementedBy(EventWriter))
Example #10
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventPrinter))
     self.assertTrue(IPlugin.implementedBy(EventPrinter))