예제 #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
파일: test_athena.py 프로젝트: calston/tums
 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))