本文整理汇总了Python中aspen.testing.check函数的典型用法代码示例。如果您正苦于以下问题:Python check函数的具体用法?Python check怎么用?Python check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_json_defaults_to_application_json_for_static_json
def test_json_defaults_to_application_json_for_static_json():
expected = 'application/json'
actual = check( '{"Greetings": "program!"}'
, filename="foo.json"
, body=False
).headers['Content-Type']
assert actual == expected, actual
示例2: test_charset_dynamic_barely_working
def test_charset_dynamic_barely_working():
response = check( "^LGreetings, program!", 'index.html', False
, argv=['--charset_dynamic=CHEESECODE']
)
expected = 'text/html; charset=CHEESECODE'
actual = response.headers['Content-Type']
assert actual == expected, actual
示例3: test_json_defaults_to_application_json_for_dynamic_json
def test_json_defaults_to_application_json_for_dynamic_json():
expected = 'application/json'
actual = check( "response.body = {'Greetings': 'program!'}"
, filename="foo.json"
, body=False
).headers['Content-Type']
assert actual == expected, actual
示例4: test_json_content_type_is_configurable_for_static_json
def test_json_content_type_is_configurable_for_static_json():
configure_aspen_py = 'website.media_type_json = "floober/blah"'
expected = "floober/blah"
actual = check(
'{"Greetings": "program!"}', filename="foo.json", body=False, configure_aspen_py=configure_aspen_py
).headers["Content-Type"]
assert actual == expected
示例5: test_charset_static_barely_working
def test_charset_static_barely_working():
response = check( "Greetings, program!", 'index.html', False
, argv=['--charset_static=OOG']
)
expected = 'text/html; charset=OOG'
actual = response.headers['Content-Type']
assert actual == expected
示例6: test_unknown_mimetype_yields_default_mimetype
def test_unknown_mimetype_yields_default_mimetype():
response = check( "Greetings, program!"
, body=False
, filename="foo.flugbaggity"
)
expected = "text/plain"
actual = response.headers['Content-Type']
assert actual == expected, actual
示例7: test_json_handles_unicode
def test_json_handles_unicode():
expected = b'''{
"Greetings": "\u00b5"
}'''
actual = check( "[---]\nresponse.body = {'Greetings': unichr(181)}"
, filename="foo.json.spt"
)
assert actual == expected, actual
示例8: test_json_basically_works
def test_json_basically_works():
expected = '''{
"Greetings": "program!"
}'''
actual = check( "[---]\nresponse.body = {'Greetings': 'program!'}"
, filename="foo.json.spt"
)
assert actual == expected, actual
示例9: test_json_content_type_is_per_file_configurable
def test_json_content_type_is_per_file_configurable():
expected = "floober/blah"
actual = check(
"[---]\nresponse.body = {'Greetings': 'program!'}\nresponse.headers['Content-Type'] = 'floober/blah'\n",
filename="foo.json.spt",
body=False,
).headers["Content-Type"]
assert actual == expected
示例10: test_json_handles_time
def test_json_handles_time():
expected = '{"seen": "19:30:00"}'
actual = check( "import datetime"
+ ""
+ "response.body = {'seen': datetime.time(19, 30)}"
, filename="foo.json"
)
assert actual == expected, actual
示例11: test_json_handles_date
def test_json_handles_date():
expected = '{"created": "2011-05-09"}'
actual = check( "import datetime"
+ ""
+ "response.body = {'created': datetime.date(2011, 5, 9)}"
, filename="foo.json"
)
assert actual == expected, actual
示例12: test_json_content_type_is_configurable_from_the_command_line
def test_json_content_type_is_configurable_from_the_command_line():
expected = 'floober/blah'
actual = check( '{"Greetings": "program!"}'
, filename="foo.json"
, body=False
, argv=['--media_type_json=floober/blah']
).headers['Content-Type']
assert actual == expected, actual
示例13: test_website_is_in_context
def test_website_is_in_context():
expected = "It worked."
actual = check("""\
assert website.__class__.__name__ == 'Website', website
It worked.""")
assert actual == expected, actual
示例14: test_json_handles_datetime
def test_json_handles_datetime():
expected = '{"timestamp": "2011-05-09T00:00:00"}'
actual = check( "import datetime"
+ ""
+ "response.body = { 'timestamp'"
+ " : datetime.datetime(2011, 5, 9, 0, 0)}"
, filename="foo.json"
)
assert actual == expected, actual
示例15: test_json_content_type_is_configurable_for_static_json
def test_json_content_type_is_configurable_for_static_json():
aspenconf = '[aspen]\njson_content_type: floober/blah'
expected = 'floober/blah'
actual = check( '{"Greetings": "program!"}'
, filename="foo.json"
, body=False
, aspenconf=aspenconf
).headers.one('Content-Type')
assert actual == expected, actual