Hi Luper

>>>>> "luper" == luper rouch <luper.ro...@gmail.com> writes:

luper> I have a last question, I put my plugins in a 'twisted/plugins'
luper> subfolder of my project, and running them from the command line
luper> works fine. How can I invoke them in unit tests (I need to be able
luper> to start and stop them), since the plugin files are not in a
luper> package?

I suspect some will answer "Uh, you probably shouldn't be doing that"...

But something like this will work:

    from twisted.plugin import getPlugins
    from twisted.application.service import IServiceMaker

    def getPlugin(name):
        for plugin in getPlugins(IServiceMaker):
            if hasattr(plugin, 'tapname'):
                if plugin.tapname == name:
                    return plugin
        return None

Terry

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to