本文整理汇总了Python中webtest.TestApp方法的典型用法代码示例。如果您正苦于以下问题:Python webtest.TestApp方法的具体用法?Python webtest.TestApp怎么用?Python webtest.TestApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webtest
的用法示例。
在下文中一共展示了webtest.TestApp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_different_publisher_signature
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_different_publisher_signature():
bower = bowerstatic.Bower(publisher_signature='static')
bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b'Hello!']
publisher = bower.publisher(wsgi)
c = Client(publisher)
response = c.get('/')
assert response.body == b'Hello!'
response = c.get(
'/static/components/jquery/2.1.1/dist/jquery.js')
assert response.body == b'/* jquery.js 2.1.1 */\n'
示例2: test_wrap
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_wrap():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery/dist/jquery.js')
return [b'<html><head></head><body>Hello!</body></html>']
wrapped = bower.wrap(wsgi)
c = Client(wrapped)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
response = c.get('/bowerstatic/components/jquery/2.1.1/dist/jquery.js')
assert response.body == b'/* jquery.js 2.1.1 */\n'
示例3: test_injector_specific_path
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_specific_path():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery/dist/jquery.js')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
示例4: test_injector_specific_path_wrong_file
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_specific_path_wrong_file():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
with pytest.raises(bowerstatic.Error):
include('jquery/nonexistent.js')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
c.get('/')
示例5: test_injector_wrong_component
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_wrong_component():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
with pytest.raises(bowerstatic.Error):
include('nonexistent/nonexistent.js')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
c.get('/')
示例6: test_injector_specific_resource
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_specific_resource():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
jquery = components.resource('jquery/dist/jquery.js')
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include(jquery)
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
示例7: test_injector_endpoint_path
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_endpoint_path():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
示例8: test_injector_endpoint_depends_on_main_missing
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_endpoint_depends_on_main_missing():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('depends_on_missing_main')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
# without a main, it should just include nothing
assert response.body == (
b'<html><head><script type="text/javascript" '
b'src="/bowerstatic/components/depends_on_missing_main/'
b'2.1.1/resource.js"></script></head><body>Hello!</body></html>')
示例9: test_injector_missing_version_bower_components
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_missing_version_bower_components():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('missing-version-in-dot-bower-json')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
# without a main, it should just include nothing
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/missing-version-in-dot-bower-json/'
b'1.0/example.js"></script>'
b'</head><body>Hello!</body></html>')
示例10: test_injector_endpoint_resource
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_endpoint_resource():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
jquery = components.resource('jquery')
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include(jquery)
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
示例11: test_injector_no_inclusions
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_no_inclusions():
bower = bowerstatic.Bower()
bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == b'<html><head></head><body>Hello!</body></html>'
示例12: test_injector_multiple_identical_inclusions
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_multiple_identical_inclusions():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery')
include('jquery')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == (
b'<html><head>'
b'<script type="text/javascript" '
b'src="/bowerstatic/components/jquery/2.1.1/dist/jquery.js">'
b'</script></head><body>Hello!</body></html>')
示例13: test_injector_no_head_to_inject
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_no_head_to_inject():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery/dist/jquery.js')
return [b'<html><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == b'<html><body>Hello!</body></html>'
示例14: test_injector_not_html_no_effect
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_not_html_no_effect():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
include = components.includer(environ)
include('jquery/dist/jquery.js')
return [b'Hello!']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.get('/')
assert response.body == b'Hello!'
示例15: test_injector_PUT_no_effect
# 需要导入模块: import webtest [as 别名]
# 或者: from webtest import TestApp [as 别名]
def test_injector_PUT_no_effect():
bower = bowerstatic.Bower()
components = bower.components('components', os.path.join(
os.path.dirname(__file__), 'bower_components'))
def wsgi(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html;charset=UTF-8')])
include = components.includer(environ)
include('jquery/dist/jquery.js')
return [b'<html><head></head><body>Hello!</body></html>']
injector = bower.injector(wsgi)
c = Client(injector)
response = c.put('/')
assert response.body == b'<html><head></head><body>Hello!</body></html>'