• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tap.Options类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.web.tap.Options的典型用法代码示例。如果您正苦于以下问题:Python Options类的具体用法?Python Options怎么用?Python Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Options类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_defaultPort

 def test_defaultPort(self):
     """
     If the I{--port} option is not specified, L{Options} defaults the port
     to C{8080}.
     """
     options = Options()
     options.parseOptions([])
     self.assertEqual(strports.parse(options["port"], None)[:2], ("TCP", (8080, None)))
开发者ID:jsober,项目名称:twisted,代码行数:8,代码来源:test_tap.py


示例2: test_HTTPSAcceptedOnAvailableSSL

    def test_HTTPSAcceptedOnAvailableSSL(self):
        """
        When SSL support is present, it accepts the --https option.
        """
        options = Options()

        options.parseOptions(['--https=443'])

        self.assertEqual('443', options['https'])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:9,代码来源:test_tap.py


示例3: test_add_header_parsing

 def test_add_header_parsing(self):
     """
     When --add-header is specific, the value is parsed.
     """
     options = Options()
     options.parseOptions(
         ['--add-header', 'K1: V1', '--add-header', 'K2: V2']
     )
     self.assertEqual(options['extraHeaders'], [('K1', 'V1'), ('K2', 'V2')])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:9,代码来源:test_tap.py


示例4: test_defaultPort

 def test_defaultPort(self):
     """
     If the I{--port} option is not specified, L{Options} defaults the port
     to C{8080}.
     """
     options = Options()
     options.parseOptions([])
     self.assertEqual(
         endpoints._parseServer(options['port'], None)[:2],
         ('TCP', (8080, None)))
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:10,代码来源:test_tap.py


示例5: test_defaultPersonalPath

 def test_defaultPersonalPath(self):
     """
     If the I{--port} option not specified but the I{--personal} option is,
     L{Options} defaults the port to C{UserDirectory.userSocketName} in the
     user's home directory.
     """
     options = Options()
     options.parseOptions(["--personal"])
     path = os.path.expanduser(os.path.join("~", UserDirectory.userSocketName))
     self.assertEqual(strports.parse(options["port"], None)[:2], ("UNIX", (path, None)))
开发者ID:jsober,项目名称:twisted,代码行数:10,代码来源:test_tap.py


示例6: test_defaultPersonalPath

 def test_defaultPersonalPath(self):
     """
     If the I{--port} option not specified but the I{--personal} option is,
     L{Options} defaults the port to C{UserDirectory.userSocketName} in the
     user's home directory.
     """
     options = Options()
     options.parseOptions(['--personal'])
     path = os.path.expanduser(
         os.path.join('~', UserDirectory.userSocketName))
     self.assertEqual(
         endpoints._parseServer(options['port'], None)[:2],
         ('UNIX', (path, None)))
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:13,代码来源:test_tap.py


示例7: test_personalServer

 def test_personalServer(self):
     """
     The I{--personal} option to L{makeService} causes it to return a
     service which will listen on the server address given by the I{--port}
     option.
     """
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--personal'])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:14,代码来源:test_tap.py


示例8: test_add_header_resource

 def test_add_header_resource(self):
     """
     When --add-header is specified, the resource is a composition that adds
     headers.
     """
     options = Options()
     options.parseOptions(
         ['--add-header', 'K1: V1', '--add-header', 'K2: V2']
     )
     service = makeService(options)
     resource = service.services[0].factory.resource
     self.assertIsInstance(resource, _AddHeadersResource)
     self.assertEqual(resource._headers, [('K1', 'V1'), ('K2', 'V2')])
     self.assertIsInstance(resource._originalResource, demo.Test)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:14,代码来源:test_tap.py


示例9: _pathOption

    def _pathOption(self):
        """
        Helper for the I{--path} tests which creates a directory and creates
        an L{Options} object which uses that directory as its static
        filesystem root.

        @return: A two-tuple of a L{FilePath} referring to the directory and
            the value associated with the C{'root'} key in the L{Options}
            instance after parsing a I{--path} option.
        """
        path = FilePath(self.mktemp())
        path.makedirs()
        options = Options()
        options.parseOptions(['--path', path.path])
        root = options['root']
        return path, root
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:16,代码来源:test_tap.py


示例10: test_pathServer

 def test_pathServer(self):
     """
     The I{--path} option to L{makeService} causes it to return a service
     which will listen on the server address given by the I{--port} option.
     """
     path = FilePath(self.mktemp())
     path.makedirs()
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--path', path.path])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertIsInstance(service.services[0].factory.resource, File)
     self.assertEqual(service.services[0].factory.resource.path, path.path)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:17,代码来源:test_tap.py


示例11: test_wsgi

    def test_wsgi(self):
        """
        The I{--wsgi} option takes the fully-qualifed Python name of a WSGI
        application object and creates a L{WSGIResource} at the root which
        serves that application.
        """
        options = Options()
        options.parseOptions(['--wsgi', __name__ + '.application'])
        root = options['root']
        self.assertTrue(root, WSGIResource)
        self.assertIdentical(root._reactor, reactor)
        self.assertTrue(isinstance(root._threadpool, ThreadPool))
        self.assertIdentical(root._application, application)

        # The threadpool should start and stop with the reactor.
        self.assertFalse(root._threadpool.started)
        reactor.fireSystemEvent('startup')
        self.assertTrue(root._threadpool.started)
        self.assertFalse(root._threadpool.joined)
        reactor.fireSystemEvent('shutdown')
        self.assertTrue(root._threadpool.joined)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:21,代码来源:test_tap.py



注:本文中的twisted.web.tap.Options类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python template.flattenString函数代码示例发布时间:2022-05-27
下一篇:
Python static.File类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap