• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testing.handle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中aspen.testing.handle函数的典型用法代码示例。如果您正苦于以下问题:Python handle函数的具体用法?Python handle怎么用?Python handle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了handle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_virtual_path_docs_1

def test_virtual_path_docs_1():
    mk(('%name/index.html.spt', GREETINGS_NAME_SPT))
    expected = "Greetings, aspen!"
    #import pdb; pdb.set_trace()
    response = handle('/aspen/')
    actual = response.body
    assert actual == expected, repr(actual) + " from " + repr(response)
开发者ID:Web5design,项目名称:aspen-python,代码行数:7,代码来源:test_dispatcher.py


示例2: test_redirect_has_only_location

def test_redirect_has_only_location(mk):
    mk(('index.html.spt', "from aspen import Response\n[---]\nrequest.redirect('http://elsewhere', code=304)\n[---]\n"))
    actual = handle()
    assert actual.code == 304
    headers = actual.headers
    assert len(headers) == 1
    assert headers.get('Location') is not None
开发者ID:prodigeni,项目名称:aspen-python,代码行数:7,代码来源:test_website.py


示例3: test_unavailable_knob_works

def test_unavailable_knob_works():
    mk( '.aspen'
      , ('.aspen/foo.py', 'bar = "baz"')
      , ('index.html', "import fooGreetings, {{ foo.bar }}!")
       )
    actual = handle('/', '--unavailable=1').code
    assert actual == 503, actual
开发者ID:sanyaade-webdev,项目名称:aspen,代码行数:7,代码来源:test_website.py


示例4: test_virtual_path_docs_4

def test_virtual_path_docs_4():
    mk( ( '%name/index.html.spt', GREETINGS_NAME_SPT),
        ( '%name/%cheese.txt.spt', NAME_LIKES_CHEESE_SPT)
       )
    response = handle('/chad/cheddar.txt/')
    expected = 404
    actual = response.code
    assert actual == expected, actual
开发者ID:nejstastnejsistene,项目名称:aspen-python,代码行数:8,代码来源:test_dispatcher.py


示例5: test_resources_can_import_from_dot_aspen

def test_resources_can_import_from_dot_aspen():
    mk( '.aspen'
      , ('.aspen/foo.py', 'bar = "baz"')
      , ('index.html', "import fooGreetings, {{ foo.bar }}!")
       )
    expected = "Greetings, baz!"
    actual = handle('/', '--project_root=.aspen').body
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:8,代码来源:test_website.py


示例6: test_virtual_path_docs_4

def test_virtual_path_docs_4():
    mk( ('%name/index.html', "^L\nGreetings, {{ path['name'] }}!")
      , ('%name/%cheese.txt', "{{ path['name'].title() }} likes {{ path['cheese'] }} cheese.")
       )
    response = handle('/chad/cheddar.txt/')
    expected = 404 
    actual = response.code
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:8,代码来源:test_gauntlet.py


示例7: test_virtual_path_docs_3

def test_virtual_path_docs_3():
    mk( ('%name/index.html', "^L\nGreetings, {{ request.path['name'] }}!")
      , ('%name/%cheese.txt', "^L\n{{ request.path['name'].title() }} likes {{ request.path['cheese'] }} cheese.")
       )
    response = handle('/chad/cheddar.txt')
    expected = "Chad likes cheddar cheese."
    actual = response.body
    assert actual == expected, actual
开发者ID:buchuki,项目名称:aspen,代码行数:8,代码来源:test_gauntlet.py


示例8: test_virtual_path_docs_3

def test_virtual_path_docs_3():
    mk( ( '%name/index.html.spt', GREETINGS_NAME_SPT),
        ( '%name/%cheese.txt.spt', NAME_LIKES_CHEESE_SPT)
      )
    response = handle('/chad/cheddar.txt')
    expected = "Chad likes cheddar cheese."
    actual = response.body
    assert actual == expected, actual
开发者ID:nejstastnejsistene,项目名称:aspen-python,代码行数:8,代码来源:test_dispatcher.py


示例9: test_resources_can_import_from_dot_aspen

def test_resources_can_import_from_dot_aspen():
    mk( '.aspen'
      , ('.aspen/foo.py', 'bar = "baz"')
      , ('index.html.spt', "from foo import bar\n[---]\nGreetings, %(bar)s!")
       )
    expected = "Greetings, baz!"
    project_root = os.path.join(FSFIX, '.aspen')
    actual = handle('/', '--project_root='+project_root).body
    assert actual == expected, actual
开发者ID:Web5design,项目名称:aspen-python,代码行数:9,代码来源:test_website.py


示例10: test_virtual_path_docs_6

def test_virtual_path_docs_6():
    mk( ( '%year.int/index.html'
        , "^L\nTonight we're going to party like it's {{ path['year'] }}!"
         )
       )
    response = handle('/1999/')
    expected = "Tonight we're going to party like it's 1999!"
    actual = response.body
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:9,代码来源:test_gauntlet.py


示例11: test_unavailable_knob_sets_retry_after_on_website

def test_unavailable_knob_sets_retry_after_on_website():
    mk( '.aspen'
      , ('.aspen/foo.py', 'bar = "baz"')
      , ('index.html', "import fooGreetings, {{ foo.bar }}!")
       )
    actual = handle('/', '--unavailable=10').headers['Retry-After']
    expected = datetime.datetime.utcnow().strftime('%a, %d %b %Y')
    assert actual.startswith(expected), actual
    assert actual.endswith(' +0000'), actual
开发者ID:sanyaade-webdev,项目名称:aspen,代码行数:9,代码来源:test_website.py


示例12: test_virtual_path_docs_5

def test_virtual_path_docs_5():
    mk( ( '%name/index.html.spt', GREETINGS_NAME_SPT),
        ( '%name/%cheese.txt.spt', NAME_LIKES_CHEESE_SPT),
        ( '%year.int/index.html.spt', PARTY_LIKE_YEAR_SPT)
       )
    response = handle('/1999/')
    expected = "Greetings, 1999!"
    actual = response.body
    assert actual == expected, actual
开发者ID:nejstastnejsistene,项目名称:aspen-python,代码行数:9,代码来源:test_dispatcher.py


示例13: test_path_part_params_are_available

def test_path_part_params_are_available():
    mk(('/foo/index.html.spt', """
if 'b' in path.parts[0].params:
    a = path.parts[0].params['a']
[---]
%(a)s"""))
    expected = "3"
    actual = handle('/foo;a=1;b;a=3/').body
    assert actual == expected, actual + " isn't " + expected
开发者ID:nejstastnejsistene,项目名称:aspen-python,代码行数:9,代码来源:test_resources.py


示例14: test_virtual_path_docs_5

def test_virtual_path_docs_5():
    mk(
        ("%name/index.html", "^L\nGreetings, {{ path['name'] }}!"),
        ("%name/%cheese.txt", "{{ path['name'].title() }} likes {{ path['cheese'] }} cheese."),
        ("%year.int/index.html", "^L\nTonight we're going to party like it's {{ path['year'] }}!"),
    )
    response = handle("/1999/")
    expected = "Greetings, 1999!"
    actual = response.body
    assert actual == expected, actual
开发者ID:sanyaade-webdev,项目名称:aspen,代码行数:10,代码来源:test_gauntlet.py


示例15: test_normal_response_is_returned

def test_normal_response_is_returned():
    mk(('index.html', "Greetings, program!"))
    expected = '\r\n'.join("""\
HTTP/1.1
Content-Type: text/html

Greetings, program!
""".splitlines())
    actual = handle()._to_http('1.1')
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:10,代码来源:test_website.py


示例16: test_indirect_negotiation_with_unsupported_media_type_is_404

def test_indirect_negotiation_with_unsupported_media_type_is_404():
    mk(('/foo', INDIRECTLY_NEGOTIATED_RESOURCE))
    response = handle('/foo.jpg')
    actual = response.code
    assert actual == 404, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:5,代码来源:test_negotiated_resource.py


示例17: test_indirect_negotiation_sets_media_type_to_secondary

def test_indirect_negotiation_sets_media_type_to_secondary():
    mk(('/foo', INDIRECTLY_NEGOTIATED_RESOURCE))
    response = handle('/foo.txt')
    expected = "Greetings, program!"
    actual = response.body
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:6,代码来源:test_negotiated_resource.py


示例18: test_indirect_negotiation_sets_media_type

def test_indirect_negotiation_sets_media_type():
    mk(('/foo', INDIRECTLY_NEGOTIATED_RESOURCE))
    response = handle('/foo.html')
    expected = "<h1>Greetings, program!</h1>\n"
    actual = response.body
    assert actual == expected, actual
开发者ID:jarpineh,项目名称:aspen,代码行数:6,代码来源:test_negotiated_resource.py


示例19: test_negotiated_inside_virtual_path_with_startype_fallback

def test_negotiated_inside_virtual_path_with_startype_fallback():
    mk(('/%foo/bar.spt', INDIRECTLY_NEGOTIATED_VIRTUAL_RESOURCE_STARTYPE ))
    response = handle('/program/bar.jpg')
    expected = "Unknown request type, program!"
    actual = response.body.strip()
    assert actual == expected, "got " + repr(actual) + " instead of " + repr(expected)
开发者ID:ArmstrongJ,项目名称:aspen-python,代码行数:6,代码来源:test_negotiated_resource.py


示例20: test_negotiated_inside_virtual_path_with_startype_partial_match

def test_negotiated_inside_virtual_path_with_startype_partial_match():
    mk(('/%foo/bar.spt', INDIRECTLY_NEGOTIATED_VIRTUAL_RESOURCE_STARTYPE ))
    response = handle('/program/bar.txt')
    expected = "Greetings, program!"
    actual = response.body
    assert actual == expected, "got " + repr(actual) + " instead of " + repr(expected)
开发者ID:ArmstrongJ,项目名称:aspen-python,代码行数:6,代码来源:test_negotiated_resource.py



注:本文中的aspen.testing.handle函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing.mk函数代码示例发布时间:2022-05-24
下一篇:
Python testing.fix函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap