本文整理汇总了Python中werkzeug.test.EnvironBuilder.form['foo']方法的典型用法代码示例。如果您正苦于以下问题:Python EnvironBuilder.form['foo']方法的具体用法?Python EnvironBuilder.form['foo']怎么用?Python EnvironBuilder.form['foo']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.test.EnvironBuilder
的用法示例。
在下文中一共展示了EnvironBuilder.form['foo']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_environ_builder_content_type
# 需要导入模块: from werkzeug.test import EnvironBuilder [as 别名]
# 或者: from werkzeug.test.EnvironBuilder import form['foo'] [as 别名]
def test_environ_builder_content_type(self):
builder = EnvironBuilder()
assert builder.content_type is None
builder.method = 'POST'
assert builder.content_type == 'application/x-www-form-urlencoded'
builder.form['foo'] = 'bar'
assert builder.content_type == 'application/x-www-form-urlencoded'
builder.files.add_file('blafasel', StringIO('foo'), 'test.txt')
assert builder.content_type == 'multipart/form-data'
req = builder.get_request()
assert req.form['foo'] == 'bar'
assert req.files['blafasel'].read() == 'foo'
示例2: test_environ_builder_content_type
# 需要导入模块: from werkzeug.test import EnvironBuilder [as 别名]
# 或者: from werkzeug.test.EnvironBuilder import form['foo'] [as 别名]
def test_environ_builder_content_type(self):
builder = EnvironBuilder()
self.assert_is_none(builder.content_type)
builder.method = 'POST'
self.assert_equal(builder.content_type, 'application/x-www-form-urlencoded')
builder.form['foo'] = 'bar'
self.assert_equal(builder.content_type, 'application/x-www-form-urlencoded')
builder.files.add_file('blafasel', BytesIO(b'foo'), 'test.txt')
self.assert_equal(builder.content_type, 'multipart/form-data')
req = builder.get_request()
self.assert_strict_equal(req.form['foo'], u'bar')
self.assert_strict_equal(req.files['blafasel'].read(), b'foo')
示例3: test_environ_builder_content_type
# 需要导入模块: from werkzeug.test import EnvironBuilder [as 别名]
# 或者: from werkzeug.test.EnvironBuilder import form['foo'] [as 别名]
def test_environ_builder_content_type():
builder = EnvironBuilder()
assert builder.content_type is None
builder.method = 'POST'
assert builder.content_type is None
builder.method = 'PUT'
assert builder.content_type is None
builder.method = 'PATCH'
assert builder.content_type is None
builder.method = 'DELETE'
assert builder.content_type is None
builder.method = 'GET'
assert builder.content_type == None
builder.form['foo'] = 'bar'
assert builder.content_type == 'application/x-www-form-urlencoded'
builder.files.add_file('blafasel', BytesIO(b'foo'), 'test.txt')
assert builder.content_type == 'multipart/form-data'
req = builder.get_request()
strict_eq(req.form['foo'], u'bar')
strict_eq(req.files['blafasel'].read(), b'foo')