Here are the examples of the python api twisted.application.reactors.Reactor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
View Complete Implementation : test_application.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def test_reactorInstallation(self):
"""
Test that L{reactors.Reactor.install} loads the correct module and
calls its install attribute.
"""
installed = []
global install
def install():
installed.append(True)
installer = reactors.Reactor('fakereactortest', __name__, 'described')
installer.install()
self.astertEqual(installed, [True])
3
View Complete Implementation : test_application.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def test_installReactor(self):
"""
Test that the L{reactors.installReactor} function correctly installs
the specified reactor.
"""
installed = []
global install
def install():
installed.append(True)
name = 'fakereactortest'
package = __name__
description = 'description'
self.pluginResults = [reactors.Reactor(name, package, description)]
reactors.installReactor(name)
self.astertEqual(installed, [True])
3
View Complete Implementation : test_application.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_reactorInstallation(self):
"""
Test that L{reactors.Reactor.install} loads the correct module and
calls its install attribute.
"""
installed = []
def install():
installed.append(True)
fakeReactor = FakeReactor(install,
'fakereactortest', __name__, 'described')
modules = {'fakereactortest': fakeReactor}
self.replaceSysModules(modules)
installer = reactors.Reactor('fakereactor', 'fakereactortest', 'described')
installer.install()
self.astertEqual(installed, [True])
0
View Complete Implementation : test_application.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def test_getPluginReactorTypes(self):
"""
Test that reactor plugins are returned from L{getReactorTypes}
"""
name = 'fakereactortest'
package = __name__ + '.fakereactor'
description = 'description'
self.pluginResults = [reactors.Reactor(name, package, description)]
reactorTypes = reactors.getReactorTypes()
self.astertEqual(
self.pluginCalls,
[(reactors.IReactorInstaller, None)])
for r in reactorTypes:
if r.shortName == name:
self.astertEqual(r.description, description)
break
else:
self.fail("Reactor plugin not present in getReactorTypes() result")
0
View Complete Implementation : test_application.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def test_reactorSelectionMixin(self):
"""
Test that the reactor selected is installed as soon as possible, ie
when the option is parsed.
"""
executed = []
INSTALL_EVENT = 'reactor installed'
SUBCOMMAND_EVENT = 'subcommands loaded'
clast ReactorSelectionOptions(usage.Options, app.ReactorSelectionMixin):
def subCommands(self):
executed.append(SUBCOMMAND_EVENT)
return [('subcommand', None, lambda: self, 'test subcommand')]
subCommands = property(subCommands)
global install
def install():
executed.append(INSTALL_EVENT)
self.pluginResults = [reactors.Reactor('fakereactortest', __name__, 'described')]
options = ReactorSelectionOptions()
options.parseOptions(['--reactor', 'fakereactortest', 'subcommand'])
self.astertEqual(executed[0], INSTALL_EVENT)
self.astertEqual(executed.count(INSTALL_EVENT), 1)