dispatch_table_test.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:aspen.py 作者: AspenWeb 项目源码 文件源码
def test_all_table_entries(harness, files, request_uri, expected):
    # set up the specified files
    realfiles = tuple([ f if f.endswith('/') else (f, GENERIC_SPT) for f in files ])
    harness.fs.www.mk(*realfiles)
    try:
        state = harness._hit('GET', request_uri, want='state',
                             return_after='dispatch_path_to_filesystem')
    except exceptions.NotFound:
        result = '404'
    except exceptions.Redirect as err:
        result = '302 ' + err.message
    else:
        result = '200'
        path = format_result(**state)
        if os.sep != posixpath.sep:
            path = path.replace(os.sep, posixpath.sep)
        path = path[len(harness.fs.www.root)+1:]
        if path:
            result += " " + path
    if expected.endswith("*"):
        expected = expected[:-1]
    assert result == expected, "Requesting %r, got %r instead of %r" % (request_uri, result, expected)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号