示例#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')
示例#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')
示例#3
0
文件: plugin.py 项目: dliverman/bravo
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)
示例#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))
示例#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)
示例#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)
示例#7
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventWriter))
     self.assertTrue(IPlugin.implementedBy(EventWriter))
     self.assertTrue(IHasOptions.implementedBy(EventWriter))
示例#8
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventPrinter))
     self.assertTrue(IPlugin.implementedBy(EventPrinter))
示例#9
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventWriter))
     self.assertTrue(IPlugin.implementedBy(EventWriter))
     self.assertTrue(IHasOptions.implementedBy(EventWriter))
示例#10
0
 def test_interface(self):
     self.assertTrue(IHandler.implementedBy(EventPrinter))
     self.assertTrue(IPlugin.implementedBy(EventPrinter))