mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
Py3: Use BytesIO instead of StringIO
This commit is contained in:
parent
4f97216501
commit
0280af9522
@ -1,4 +1,4 @@
|
|||||||
from six.moves import cStringIO as StringIO
|
from six import BytesIO
|
||||||
|
|
||||||
import netlib
|
import netlib
|
||||||
from netlib import tcp
|
from netlib import tcp
|
||||||
@ -25,7 +25,7 @@ def default_settings():
|
|||||||
|
|
||||||
|
|
||||||
def test_make_error_response():
|
def test_make_error_response():
|
||||||
d = StringIO()
|
d = BytesIO()
|
||||||
s = http2.make_error_response("foo", "bar")
|
s = http2.make_error_response("foo", "bar")
|
||||||
language.serve(s, d, default_settings())
|
language.serve(s, d, default_settings())
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class TestRequest:
|
|||||||
assert r[1].method.string() == "GET"
|
assert r[1].method.string() == "GET"
|
||||||
|
|
||||||
def test_render_simple(self):
|
def test_render_simple(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_request("GET:'/foo'")
|
r = parse_request("GET:'/foo'")
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
@ -126,7 +126,7 @@ class TestRequest:
|
|||||||
assert r.headers[0].values(default_settings()) == ("user-agent", user_agents.get_by_shortcut('a')[2])
|
assert r.headers[0].values(default_settings()) == ("user-agent", user_agents.get_by_shortcut('a')[2])
|
||||||
|
|
||||||
def test_render_with_headers(self):
|
def test_render_with_headers(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_request('GET:/foo:h"foo"="bar"')
|
r = parse_request('GET:/foo:h"foo"="bar"')
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
@ -142,7 +142,7 @@ class TestRequest:
|
|||||||
assert r.values(default_settings())
|
assert r.values(default_settings())
|
||||||
|
|
||||||
def test_render_with_body(self):
|
def test_render_with_body(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_request("GET:'/foo':bfoobar")
|
r = parse_request("GET:'/foo':bfoobar")
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
@ -199,7 +199,7 @@ class TestResponse:
|
|||||||
assert r.body.string() == "foobar"
|
assert r.body.string() == "foobar"
|
||||||
|
|
||||||
def test_render_simple(self):
|
def test_render_simple(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_response('200')
|
r = parse_response('200')
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
@ -208,7 +208,7 @@ class TestResponse:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_render_with_headers(self):
|
def test_render_with_headers(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_response('200:h"foo"="bar"')
|
r = parse_response('200:h"foo"="bar"')
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
@ -217,7 +217,7 @@ class TestResponse:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_render_with_body(self):
|
def test_render_with_body(self):
|
||||||
s = StringIO()
|
s = BytesIO()
|
||||||
r = parse_response('200:bfoobar')
|
r = parse_response('200:bfoobar')
|
||||||
assert language.serve(
|
assert language.serve(
|
||||||
r,
|
r,
|
||||||
|
Loading…
Reference in New Issue
Block a user