mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 19:08:44 +00:00
fix tests
This commit is contained in:
parent
b70663f434
commit
85aa5da6e3
@ -76,7 +76,7 @@ class Headers(MultiDict):
|
||||
For use with the "Set-Cookie" header, see :py:meth:`get_all`.
|
||||
"""
|
||||
|
||||
def __init__(self, fields=None, **headers):
|
||||
def __init__(self, fields=(), **headers):
|
||||
"""
|
||||
Args:
|
||||
fields: (optional) list of ``(name, value)`` header byte tuples,
|
||||
|
@ -19,7 +19,7 @@ host_header_re = re.compile(r"^(?P<host>[^:]+|\[.+\])(?::(?P<port>\d+))?$")
|
||||
|
||||
|
||||
class RequestData(MessageData):
|
||||
def __init__(self, first_line_format, method, scheme, host, port, path, http_version, headers=None, content=None,
|
||||
def __init__(self, first_line_format, method, scheme, host, port, path, http_version, headers=(), content=None,
|
||||
timestamp_start=None, timestamp_end=None):
|
||||
if not isinstance(headers, Headers):
|
||||
headers = Headers(headers)
|
||||
|
@ -11,7 +11,7 @@ from .. import utils
|
||||
|
||||
|
||||
class ResponseData(MessageData):
|
||||
def __init__(self, http_version, status_code, reason=None, headers=None, content=None,
|
||||
def __init__(self, http_version, status_code, reason=None, headers=(), content=None,
|
||||
timestamp_start=None, timestamp_end=None):
|
||||
if not isinstance(headers, Headers):
|
||||
headers = Headers(headers)
|
||||
|
@ -22,7 +22,7 @@ def python_equals(testdata, text):
|
||||
|
||||
req_get = lambda: netlib.tutils.treq(method='GET', content='', path=b"/path?a=foo&a=bar&b=baz")
|
||||
|
||||
req_post = lambda: netlib.tutils.treq(method='POST', headers=None)
|
||||
req_post = lambda: netlib.tutils.treq(method='POST', headers=())
|
||||
|
||||
req_patch = lambda: netlib.tutils.treq(method='PATCH', path=b"/path?query=param")
|
||||
|
||||
|
@ -460,7 +460,7 @@ class TestAssembleRequest(object):
|
||||
b'',
|
||||
b'/',
|
||||
b"HTTP/2.0",
|
||||
None,
|
||||
(),
|
||||
None,
|
||||
))
|
||||
assert len(bytes) == 1
|
||||
@ -475,7 +475,7 @@ class TestAssembleRequest(object):
|
||||
b'',
|
||||
b'/',
|
||||
b"HTTP/2.0",
|
||||
None,
|
||||
(),
|
||||
None,
|
||||
)
|
||||
req.stream_id = 0x42
|
||||
|
@ -13,7 +13,7 @@ class TestRequestData(object):
|
||||
with raises(ValueError):
|
||||
treq(headers="foobar")
|
||||
|
||||
assert isinstance(treq(headers=None).headers, Headers)
|
||||
assert isinstance(treq(headers=()).headers, Headers)
|
||||
|
||||
|
||||
class TestRequestCore(object):
|
||||
|
@ -15,7 +15,7 @@ class TestResponseData(object):
|
||||
with raises(ValueError):
|
||||
tresp(headers="foobar")
|
||||
|
||||
assert isinstance(tresp(headers=None).headers, Headers)
|
||||
assert isinstance(tresp(headers=()).headers, Headers)
|
||||
|
||||
|
||||
class TestResponseCore(object):
|
||||
|
Loading…
Reference in New Issue
Block a user