python类compat()的实例源码

test_requests.py 文件源码 项目:ruffruffs 作者: di 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_unicode_header_name(self, httpbin):
        requests.put(
            httpbin('put'),
            headers={str('Content-Type'): 'application/octet-stream'},
            data='\xff')  # compat.str is unicode.
test_requests.py 文件源码 项目:filegardener 作者: smorin 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_unicode_header_name(self, httpbin):
        requests.put(
            httpbin('put'),
            headers={str('Content-Type'): 'application/octet-stream'},
            data='\xff')  # compat.str is unicode.
test_requests.py 文件源码 项目:filegardener 作者: smorin 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_unicode_header_name(self, httpbin):
        requests.put(
            httpbin('put'),
            headers={str('Content-Type'): 'application/octet-stream'},
            data='\xff')  # compat.str is unicode.
github.py 文件源码 项目:img2url 作者: huntzhan 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def _to_binary(body):
    from requests.compat import json as complexjson
    data = complexjson.dumps(body)
    if not isinstance(data, bytes):
        return data.encode('utf-8')
    else:
        return data
test_requests.py 文件源码 项目:Codeforces-Sublime-Plugin 作者: karunk 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_unicode_header_name(self, httpbin):
        requests.put(
            httpbin('put'),
            headers={str('Content-Type'): 'application/octet-stream'},
            data='\xff')  # compat.str is unicode.
test_requests.py 文件源码 项目:Codeforces-Sublime-Plugin 作者: karunk 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def test_guess_filename_with_file_like_obj(self):
        from requests.utils import guess_filename
        from requests import compat
        fake = type('Fake', (object,), {'name': b'value'})()
        guessed_name = guess_filename(fake)
        assert b'value' == guessed_name
        assert isinstance(guessed_name, compat.bytes)
test_requests.py 文件源码 项目:Codeforces-Sublime-Plugin 作者: karunk 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_guess_filename_with_unicode_name(self):
        from requests.utils import guess_filename
        from requests import compat
        filename = b'value'.decode('utf-8')
        fake = type('Fake', (object,), {'name': filename})()
        guessed_name = guess_filename(fake)
        assert filename == guessed_name
        assert isinstance(guessed_name, compat.str)
test_requests.py 文件源码 项目:Codeforces-Sublime-Plugin 作者: karunk 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def test_get_auth_from_url(self):
        """Ensures that username and password in well-encoded URI as per
        RFC 3986 are correclty extracted."""
        from requests.utils import get_auth_from_url
        from requests.compat import quote
        percent_encoding_test_chars = "%!*'();:@&=+$,/?#[] "
        url_address = "request.com/url.html#test"
        url = "http://" + quote(
            percent_encoding_test_chars, '') + ':' + quote(
            percent_encoding_test_chars, '') + '@' + url_address
        (username, password) = get_auth_from_url(url)
        assert username == percent_encoding_test_chars
        assert password == percent_encoding_test_chars


问题


面经


文章

微信
公众号

扫码关注公众号