当前位置: 首页>>代码示例>>Python>>正文


Python tools.tob函数代码示例

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


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


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