test_unicode.py 文件源码

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

项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码
def test_url_utf8():
    """Allow UTF8 characters in URLs themselves."""
    outs = ('<a href="{0!s}" rel="nofollow">{0!s}</a>',
            '<a rel="nofollow" href="{0!s}">{0!s}</a>')

    out = lambda url: [x.format(url) for x in outs]

    tests = (
        ('http://éxámplé.com/', out('http://éxámplé.com/')),
        ('http://éxámplé.com/íàñá/', out('http://éxámplé.com/íàñá/')),
        ('http://éxámplé.com/íàñá/?foo=bar',
         out('http://éxámplé.com/íàñá/?foo=bar')),
        ('http://éxámplé.com/íàñá/?fóo=bár',
         out('http://éxámplé.com/íàñá/?fóo=bár')),
    )

    def check(test, expected_output):
        in_(expected_output, linkify(test))

    for test, expected_output in tests:
        yield check, test, expected_output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号