本文整理汇总了Python中tests.strict_eq函数的典型用法代码示例。如果您正苦于以下问题:Python strict_eq函数的具体用法?Python strict_eq怎么用?Python strict_eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strict_eq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_map_repr
def test_map_repr():
m = r.Map([
r.Rule(u'/wat', endpoint='enter'),
r.Rule(u'/woop', endpoint='foobar')
])
rv = repr(m)
strict_eq(rv,
"Map([<Rule '/woop' -> foobar>, <Rule '/wat' -> enter>])")
开发者ID:brunoais,项目名称:werkzeug,代码行数:8,代码来源:test_routing.py
示例2: test_authenticate_mixin
def test_authenticate_mixin():
resp = wrappers.Response()
resp.www_authenticate.type = 'basic'
resp.www_authenticate.realm = 'Testing'
strict_eq(resp.headers['WWW-Authenticate'], u'Basic realm="Testing"')
resp.www_authenticate.realm = None
resp.www_authenticate.type = None
assert 'WWW-Authenticate' not in resp.headers
开发者ID:jasco,项目名称:werkzeug,代码行数:8,代码来源:test_wrappers.py
示例3: test_delete_requests_with_form
def test_delete_requests_with_form():
@Request.application
def test_app(request):
return Response(request.form.get('x', None))
client = Client(test_app, Response)
resp = client.delete('/', data={'x': 42})
strict_eq(resp.data, b'42')
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:8,代码来源:test_test.py
示例4: test_stream_only_mixing
def test_stream_only_mixing():
request = wrappers.PlainRequest.from_values(
data=b'foo=blub+hehe',
content_type='application/x-www-form-urlencoded'
)
assert list(request.files.items()) == []
assert list(request.form.items()) == []
pytest.raises(AttributeError, lambda: request.data)
strict_eq(request.stream.read(), b'foo=blub+hehe')
开发者ID:jasco,项目名称:werkzeug,代码行数:9,代码来源:test_wrappers.py
示例5: test_secure
def test_secure(self):
response = wrappers.BaseResponse()
response.set_cookie('foo', value='bar', max_age=60, expires=0,
path='/blub', domain='example.org', secure=True)
strict_eq(response.headers.to_wsgi_list(), [
('Content-Type', 'text/plain; charset=utf-8'),
('Set-Cookie', 'foo=bar; Domain=example.org; Expires=Thu, '
'01-Jan-1970 00:00:00 GMT; Max-Age=60; Secure; Path=/blub')
])
开发者ID:jasco,项目名称:werkzeug,代码行数:9,代码来源:test_wrappers.py
示例6: test_access_route
def test_access_route():
req = wrappers.Request.from_values(headers={"X-Forwarded-For": "192.168.1.2, 192.168.1.1"})
req.environ["REMOTE_ADDR"] = "192.168.1.3"
assert req.access_route == ["192.168.1.2", "192.168.1.1"]
strict_eq(req.remote_addr, "192.168.1.3")
req = wrappers.Request.from_values()
req.environ["REMOTE_ADDR"] = "192.168.1.3"
strict_eq(list(req.access_route), ["192.168.1.3"])
开发者ID:tsampi,项目名称:tsampi-0,代码行数:9,代码来源:test_wrappers.py
示例7: test_multi_value_submit
def test_multi_value_submit():
c = Client(multi_value_post_app, response_wrapper=BaseResponse)
data = {"field": ["val1", "val2"]}
resp = c.post("/", data=data)
strict_eq(resp.status_code, 200)
c = Client(multi_value_post_app, response_wrapper=BaseResponse)
data = MultiDict({"field": ["val1", "val2"]})
resp = c.post("/", data=data)
strict_eq(resp.status_code, 200)
开发者ID:ajones620,项目名称:werkzeug,代码行数:9,代码来源:test_test.py
示例8: test_path_info_script_name_unquoting
def test_path_info_script_name_unquoting():
def test_app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [environ['PATH_INFO'] + '\n' + environ['SCRIPT_NAME']]
c = Client(test_app, response_wrapper=BaseResponse)
resp = c.get('/foo%40bar')
strict_eq(resp.data, b'/[email protected]\n')
c = Client(test_app, response_wrapper=BaseResponse)
resp = c.get('/foo%40bar', 'http://localhost/bar%40baz')
strict_eq(resp.data, b'/[email protected]\n/[email protected]')
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:10,代码来源:test_test.py
示例9: test_post_with_file_descriptor
def test_post_with_file_descriptor(tmpdir):
c = Client(Response(), response_wrapper=Response)
f = tmpdir.join('some-file.txt')
f.write('foo')
with open(f.strpath, mode='rt') as data:
resp = c.post('/', data=data)
strict_eq(resp.status_code, 200)
with open(f.strpath, mode='rb') as data:
resp = c.post('/', data=data)
strict_eq(resp.status_code, 200)
开发者ID:brunoais,项目名称:werkzeug,代码行数:10,代码来源:test_test.py
示例10: test_url_joining
def test_url_joining():
strict_eq(urls.url_join('/foo', '/bar'), '/bar')
strict_eq(urls.url_join('http://example.com/foo', '/bar'),
'http://example.com/bar')
strict_eq(urls.url_join('file:///tmp/', 'test.html'),
'file:///tmp/test.html')
strict_eq(urls.url_join('file:///tmp/x', 'test.html'),
'file:///tmp/test.html')
strict_eq(urls.url_join('file:///tmp/x', '../../../x.html'),
'file:///x.html')
开发者ID:char101,项目名称:werkzeug,代码行数:10,代码来源:test_urls.py
示例11: test_environ_nonascii_pathinfo
def test_environ_nonascii_pathinfo():
environ = create_environ(u'/лошадь')
m = r.Map([
r.Rule(u'/', endpoint='index'),
r.Rule(u'/лошадь', endpoint='horse')
])
a = m.bind_to_environ(environ)
strict_eq(a.match(u'/'), ('index', {}))
strict_eq(a.match(u'/лошадь'), ('horse', {}))
pytest.raises(r.NotFound, a.match, u'/барсук')
开发者ID:brunoais,项目名称:werkzeug,代码行数:10,代码来源:test_routing.py
示例12: test_ie7_unc_path
def test_ie7_unc_path(self):
client = Client(form_data_consumer, Response)
data_file = join(dirname(__file__), 'multipart', 'ie7_full_path_request.txt')
data = get_contents(data_file)
boundary = '---------------------------7da36d1b4a0164'
response = client.post('/?object=cb_file_upload_multiple', data=data, content_type=
'multipart/form-data; boundary="%s"' % boundary, content_length=len(data))
lines = response.get_data().split(b'\n', 3)
strict_eq(lines[0],
repr(u'Sellersburg Town Council Meeting 02-22-2010doc.doc').encode('ascii'))
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:10,代码来源:test_formparser.py
示例13: test_empty_keys_are_ignored
def test_empty_keys_are_ignored(self):
strict_eq(
dict(http.parse_cookie(
'first=IamTheFirst ; a=1; a=2 ;second=andMeTwo; ; '
)),
{
'first': u'IamTheFirst',
'a': u'2',
'second': u'andMeTwo'
}
)
开发者ID:brunoais,项目名称:werkzeug,代码行数:11,代码来源:test_http.py
示例14: test_full_url_requests_with_args
def test_full_url_requests_with_args():
base = 'http://example.com/'
@Request.application
def test_app(request):
return Response(request.args['x'])
client = Client(test_app, Response)
resp = client.get('/?x=42', base)
strict_eq(resp.data, b'42')
resp = client.get('http://www.example.com/?x=23', base)
strict_eq(resp.data, b'23')
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:11,代码来源:test_test.py
示例15: test_access_route
def test_access_route():
req = wrappers.Request.from_values(headers={
'X-Forwarded-For': '192.168.1.2, 192.168.1.1'
})
req.environ['REMOTE_ADDR'] = '192.168.1.3'
assert req.access_route == ['192.168.1.2', '192.168.1.1']
strict_eq(req.remote_addr, '192.168.1.3')
req = wrappers.Request.from_values()
req.environ['REMOTE_ADDR'] = '192.168.1.3'
strict_eq(list(req.access_route), ['192.168.1.3'])
开发者ID:jasco,项目名称:werkzeug,代码行数:11,代码来源:test_wrappers.py
示例16: test_content_type
def test_content_type():
@Request.application
def test_app(request):
return Response(request.content_type)
client = Client(test_app, Response)
resp = client.get('/', data=b'testing', mimetype='text/css')
strict_eq(resp.data, b'text/css; charset=utf-8')
resp = client.get('/', data=b'testing', mimetype='application/octet-stream')
strict_eq(resp.data, b'application/octet-stream')
开发者ID:brunoais,项目名称:werkzeug,代码行数:11,代码来源:test_test.py
示例17: test_proxy_fix_weird_enum
def test_proxy_fix_weird_enum(self):
@fixers.ProxyFix
@Request.application
def app(request):
return Response(request.remote_addr)
environ = dict(create_environ(),
HTTP_X_FORWARDED_FOR=',',
REMOTE_ADDR='127.0.0.1',
)
response = Response.from_app(app, environ)
strict_eq(response.get_data(), b'127.0.0.1')
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:12,代码来源:test_fixers.py
示例18: test_redirect_path_quoting
def test_redirect_path_quoting():
url_map = r.Map([
r.Rule('/<category>', defaults={'page': 1}, endpoint='category'),
r.Rule('/<category>/page/<int:page>', endpoint='category')
])
adapter = url_map.bind('example.com')
with pytest.raises(r.RequestRedirect) as excinfo:
adapter.match('/foo bar/page/1')
response = excinfo.value.get_response({})
strict_eq(response.headers['location'],
u'http://example.com/foo%20bar')
开发者ID:brunoais,项目名称:werkzeug,代码行数:12,代码来源:test_routing.py
示例19: test_bad_cookies
def test_bad_cookies(self):
strict_eq(
dict(http.parse_cookie(
'first=IamTheFirst ; a=1; oops ; a=2 ;second = andMeTwo;'
)),
{
'first': u'IamTheFirst',
'a': u'2',
'oops': u'',
'second': u'andMeTwo',
}
)
开发者ID:brunoais,项目名称:werkzeug,代码行数:12,代码来源:test_http.py
示例20: test_environ_builder_stream_switch
def test_environ_builder_stream_switch():
d = MultiDict(dict(foo=u'bar', blub=u'blah', hu=u'hum'))
for use_tempfile in False, True:
stream, length, boundary = stream_encode_multipart(
d, use_tempfile, threshold=150)
assert isinstance(stream, BytesIO) != use_tempfile
form = parse_form_data({'wsgi.input': stream, 'CONTENT_LENGTH': str(length),
'CONTENT_TYPE': 'multipart/form-data; boundary="%s"' %
boundary})[1]
strict_eq(form, d)
stream.close()
开发者ID:ArielAzia,项目名称:werkzeug,代码行数:12,代码来源:test_test.py
注:本文中的tests.strict_eq函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论