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

Python tools.tob函数代码示例

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

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



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

示例1: tearDown

 def tearDown(self):
     while self.p.poll() is None:
         os.kill(self.p.pid, signal.SIGINT)
         time.sleep(0.1)
         if self.p.poll() is None:
             os.kill(self.p.pid, signal.SIGTERM)
     for stream in (self.p.stdout, self.p.stderr):
         for line in stream:
             if tob('Warning') in line \
             or tob('Error') in line or True:
                 print line.strip().decode('utf8')
开发者ID:babs,项目名称:bottle,代码行数:11,代码来源:test_server.py


示例2: test_default

 def test_default(self):
     """ WSGI: default routes """
     @bottle.route('/')
     def test2(): return 'test'
     self.assertEqual(404, self.urlopen('/not/found').code)
     self.assertEqual(200, self.urlopen('/').code)
     self.assertEqual(tob('test'), self.urlopen('/').read())
     @bottle.default()
     def test(): return 'default'
     self.assertEqual(200, self.urlopen('/not/found').code)
     self.assertEqual(tob('default'), self.urlopen('/not/found').read())
     self.assertEqual(200, self.urlopen('/').code)
     self.assertEqual(tob('test'), self.urlopen('/').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:13,代码来源:test_wsgi.py


示例3: test_headget

 def test_headget(self):
     """ WSGI: HEAD routes and GET fallback"""
     @bottle.route('/get')
     def test(): return 'test'
     @bottle.route('/head', method='HEAD')
     def test2(): return 'test'
     # GET -> HEAD
     self.assertEqual(404, self.urlopen('/head').code)
     # HEAD -> HEAD
     self.assertEqual(200, self.urlopen('/head', method='HEAD').code)
     self.assertEqual(tob(''), self.urlopen('/head', method='HEAD').read())
     # HEAD -> GET
     self.assertEqual(200, self.urlopen('/get', method='HEAD').code)
     self.assertEqual(tob(''), self.urlopen('/get', method='HEAD').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:14,代码来源:test_wsgi.py


示例4: tearDown

    def tearDown(self):
        if self.skip: return

        if self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGINT)
            time.sleep(0.5)
        while self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGTERM)
            time.sleep(1)

        for stream in (self.p.stdout, self.p.stderr):
            for line in stream:
                if tob('warning') in line.lower():
                    tools.warn(line.strip().decode('utf8'))
                elif tob('error') in line.lower():
                    raise AssertionError(line.strip().decode('utf8'))
开发者ID:FedericoCeratto,项目名称:bottle,代码行数:16,代码来源:test_server.py


示例5: tearDown

 def tearDown(self):
     if self.skip: return
     for i in range(10):
         if self.p.poll() != None: break
         os.kill(self.p.pid, signal.SIGINT)
         time.sleep(0.1*i)
     for i in range(10):
         if self.p.poll() != None: break
         os.kill(self.p.pid, signal.SIGINT)
         time.sleep(i)
     for stream in (self.p.stdout, self.p.stderr):
         for line in stream:
             if tob('warning') in line.lower():
                 tools.warn(line.strip().decode('utf8'))
             elif tob('error') in line.lower():
                 raise AssertionError(line.strip().decode('utf8'))
开发者ID:dmpeters,项目名称:bottle,代码行数:16,代码来源:test_server.py


示例6: test_post

 def test_post(self):
     """ WSGI: POST routes"""
     @bottle.route('/', method='POST')
     def test(): return 'test'
     self.assertEqual(404, self.urlopen('/not/found').code)
     self.assertEqual(404, self.urlopen('/').code)
     self.assertEqual(tob('test'), self.urlopen('/', post="var=value").read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:7,代码来源:test_wsgi.py


示例7: test_303

 def test_303(self):
     """ WSGI: redirect (HTTP 303) """
     @bottle.route('/')
     def test(): bottle.redirect('/yes')
     @bottle.route('/yes')
     def test2(): return 'yes'
     self.assertEqual(200, self.urlopen('/').code)
     self.assertEqual(tob('yes'), self.urlopen('/').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:8,代码来源:test_wsgi.py


示例8: testWithBottle

 def testWithBottle(self):
     bottle.app.push()
     bottle.response.bind()
     bottle.response.set_cookie('key', dict(value=5), secret=tob('1234'))
     cheader = [v for k, v in bottle.response.wsgiheader() if k == 'Set-Cookie'][0]
     bottle.request.bind({'HTTP_COOKIE': cheader.split(';')[0]})
     self.assertEqual(repr(dict(value=5)), repr(bottle.request.get_cookie('key', secret=tob('1234'))))
     bottle.app.pop()
开发者ID:JeremyGrosser,项目名称:bottle,代码行数:8,代码来源:test_securecookies.py


示例9: test_casting

 def test_casting(self):
     """ WSGI: Output Casting (strings an lists) """
     @bottle.route('/str')
     def test(): return 'test'
     self.assertEqual(tob('test'), self.urlopen('/str').read())
     @bottle.route('/list')
     def test2(): return ['t','e','st']
     self.assertEqual(tob('test'), self.urlopen('/list').read())
     @bottle.route('/empty')
     def test3(): return []
     self.assertEqual(tob(''), self.urlopen('/empty').read())
     @bottle.route('/none')
     def test4(): return None
     self.assertEqual(tob(''), self.urlopen('/none').read())
     @bottle.route('/bad')
     def test5(): return 12345
     self.assertEqual(500, self.urlopen('/bad').code)
开发者ID:johnbenclark,项目名称:bottle,代码行数:17,代码来源:test_wsgi.py


示例10: test_view

 def test_view(self):
     """ WSGI: Test view-decorator (should override autojson) """
     @bottle.route('/tpl')
     @bottle.view('stpl_t2main')
     def test():
         return dict(content='1234')
     result = tob('+base+\n+main+\n!1234!\n+include+\n-main-\n+include+\n-base-\n')
     self.assertEqual('text/html; charset=UTF-8', self.urlopen('/tpl').info().get('Content-Type',''))
     self.assertEqual(result, self.urlopen('/tpl').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:9,代码来源:test_wsgi.py


示例11: test_validate

 def test_validate(self):
     """ WSGI: Test validate-decorator"""
     @bottle.route('/:var')
     @bottle.route('/')
     @bottle.validate(var=int)
     def test(var): return 'x' * var
     self.assertEqual(403, self.urlopen('/noint').code)
     self.assertEqual(403, self.urlopen('/').code)
     self.assertEqual(200, self.urlopen('/5').code)
     self.assertEqual(tob('xxx'), self.urlopen('/3').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:10,代码来源:test_wsgi.py


示例12: test_401

 def test_401(self):
     """ WSGI: abort(401, '') (HTTP 401) """
     @bottle.route('/')
     def test(): bottle.abort(401)
     self.assertEqual(401, self.urlopen('/').code)
     @bottle.error(401)
     def err(e):
         bottle.response.status = 200
         return str(type(e))
     self.assertEqual(200, self.urlopen('/').code)
     self.assertEqual(tob("<class 'bottle.HTTPError'>"), self.urlopen('/').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:11,代码来源:test_wsgi.py


示例13: test_params

 def test_params(self):
     """ Environ: GET and POST are combined in request.param """ 
     e = {}
     wsgiref.util.setup_testing_defaults(e)
     e['wsgi.input'].write(tob('b=b&c=p'))
     e['wsgi.input'].seek(0)
     e['CONTENT_LENGTH'] = '7'
     e['QUERY_STRING'] = 'a=a&c=g'
     e['REQUEST_METHOD'] = "POST"
     request.bind(e, None)
     self.assertEqual(['a','b','c'], sorted(request.params.keys()))
     self.assertEqual('p', request.params['c'])
开发者ID:Crylock,项目名称:bottle,代码行数:12,代码来源:test_environ.py


示例14: tearDown

    def tearDown(self):
        if self.skip: return

        if self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGINT)
            time.sleep(0.5)
        if self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGTERM)
            time.sleep(0.5)
        while self.p.poll() == None:
            tools.warn("Trying to kill server %r with pid %d." %
                       (self.server, self.p.pid))
            os.kill(self.p.pid, signal.SIGKILL)
            time.sleep(1)

        lines = [line for stream in (self.p.stdout, self.p.stderr) for line in stream]
        for line in lines:
            if tob('warning') in line.lower():
               tools.warn(line.strip().decode('utf8'))
            elif tob('error') in line.lower():
                raise AssertionError(line.strip().decode('utf8'))
开发者ID:oz123,项目名称:bottle,代码行数:21,代码来源:test_server.py


示例15: setUp

 def setUp(self):
     self.data = dict(a=5, b=u'unicode', c=[1,2,3,4,tob('bytestring')])
     self.key = tob('secret')
开发者ID:JeremyGrosser,项目名称:bottle,代码行数:3,代码来源:test_securecookies.py


示例16: testDeEncode

 def testDeEncode(self):
     cookie = bottle.cookie_encode(self.data, self.key)
     decoded = bottle.cookie_decode(cookie, self.key)
     self.assertEqual(self.data, decoded)
     decoded = bottle.cookie_decode(cookie+tob('x'), self.key)
     self.assertEqual(None, decoded)
开发者ID:JeremyGrosser,项目名称:bottle,代码行数:6,代码来源:test_securecookies.py


示例17: test_json

 def test_json(self):
     """ WSGI: Autojson feature """
     @bottle.route('/json')
     def test(): return {'a': 1}
     self.assertEqual(tob(r'{"a":1}'), tob('').join(self.urlopen('/json').read().split()))
     self.assertEqual('application/json', self.urlopen('/json').info().get('Content-Type',''))
开发者ID:johnbenclark,项目名称:bottle,代码行数:6,代码来源:test_wsgi.py


示例18: testIsEncoded

 def testIsEncoded(self):
     cookie = bottle.cookie_encode(self.data, self.key)
     self.assertTrue(bottle.cookie_is_encoded(cookie))
     self.assertFalse(bottle.cookie_is_encoded(tob('some string')))
开发者ID:JeremyGrosser,项目名称:bottle,代码行数:4,代码来源:test_securecookies.py


示例19: test_simple

 def test_simple(self):
     ''' Test a simple static page with this server adapter. '''
     if self.skip: return
     self.assertEqual(tob('OK'), self.fetch('test'))
开发者ID:dmpeters,项目名称:bottle,代码行数:4,代码来源:test_server.py


示例20: test_file

 def test_file(self):
     """ WSGI: Output Casting (files) """
     @bottle.route('/file')
     def test(): return StringIO('test')
     self.assertEqual(tob('test'), self.urlopen('/file').read())
开发者ID:johnbenclark,项目名称:bottle,代码行数:5,代码来源:test_wsgi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tools.tracing_import函数代码示例发布时间:2022-05-27
下一篇:
Python tools.strip函数代码示例发布时间: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