本文整理汇总了Python中twisted.scripts._twistd_unix.UnixApplicationRunner.startApplication方法的典型用法代码示例。如果您正苦于以下问题:Python UnixApplicationRunner.startApplication方法的具体用法?Python UnixApplicationRunner.startApplication怎么用?Python UnixApplicationRunner.startApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.scripts._twistd_unix.UnixApplicationRunner
的用法示例。
在下文中一共展示了UnixApplicationRunner.startApplication方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UnixApplicationRunnerStartApplicationTests
# 需要导入模块: from twisted.scripts._twistd_unix import UnixApplicationRunner [as 别名]
# 或者: from twisted.scripts._twistd_unix.UnixApplicationRunner import startApplication [as 别名]
class UnixApplicationRunnerStartApplicationTests(unittest.TestCase):
"""
Tests for L{UnixApplicationRunner.startApplication}.
"""
if _twistd_unix is None:
skip = "twistd unix not available"
def test_setupEnvironment(self):
"""
L{UnixApplicationRunner.startApplication} calls
L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
nodaemon, umask, and pidfile parameters from the configuration it is
constructed with.
"""
options = twistd.ServerOptions()
options.parseOptions([
'--nodaemon',
'--umask', '0070',
'--chroot', '/foo/chroot',
'--rundir', '/foo/rundir',
'--pidfile', '/foo/pidfile'])
application = service.Application("test_setupEnvironment")
self.runner = UnixApplicationRunner(options)
args = []
def fakeSetupEnvironment(self, chroot, rundir, nodaemon, umask, pidfile):
args.extend((chroot, rundir, nodaemon, umask, pidfile))
# Sanity check
self.assertEqual(
inspect.getargspec(self.runner.setupEnvironment),
inspect.getargspec(fakeSetupEnvironment))
self.patch(UnixApplicationRunner, 'setupEnvironment', fakeSetupEnvironment)
self.patch(UnixApplicationRunner, 'shedPrivileges', lambda *a, **kw: None)
self.patch(app, 'startApplication', lambda *a, **kw: None)
self.runner.startApplication(application)
self.assertEqual(
args,
['/foo/chroot', '/foo/rundir', True, 56, '/foo/pidfile'])