本文整理匯總了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>'