aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-07 17:50:26 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-07 17:50:26 -0700
commit76473d44e035306503a426ebcd55967798f243a1 (patch)
tree6fe75ef723b9c104897a1c025938fa3d752b3491 /test
parentf62e976e1e0245665aeeb08fa801661d6c766ba8 (diff)
downloadmitmproxy-76473d44e035306503a426ebcd55967798f243a1.tar.gz
mitmproxy-76473d44e035306503a426ebcd55967798f243a1.tar.bz2
mitmproxy-76473d44e035306503a426ebcd55967798f243a1.zip
py3++
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_examples.py14
-rw-r--r--test/mitmproxy/test_flow_export.py10
-rw-r--r--test/netlib/http/http1/test_assemble.py2
-rw-r--r--test/netlib/http/test_message.py4
4 files changed, 15 insertions, 15 deletions
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py
index 206a0366..f30973e7 100644
--- a/test/mitmproxy/test_examples.py
+++ b/test/mitmproxy/test_examples.py
@@ -84,11 +84,11 @@ def test_iframe_injector():
with example("iframe_injector.py") as ex:
pass
- flow = tutils.tflow(resp=netutils.tresp(content="<html>mitmproxy</html>"))
+ flow = tutils.tflow(resp=netutils.tresp(content=b"<html>mitmproxy</html>"))
with example("iframe_injector.py http://example.org/evil_iframe") as ex:
ex.run("response", flow)
content = flow.response.content
- assert 'iframe' in content and 'evil_iframe' in content
+ assert b'iframe' in content and b'evil_iframe' in content
def test_modify_form():
@@ -96,11 +96,11 @@ def test_modify_form():
flow = tutils.tflow(req=netutils.treq(headers=form_header))
with example("modify_form.py") as ex:
ex.run("request", flow)
- assert flow.request.urlencoded_form["mitmproxy"] == "rocks"
+ assert flow.request.urlencoded_form[b"mitmproxy"] == b"rocks"
flow.request.headers["content-type"] = ""
ex.run("request", flow)
- assert list(flow.request.urlencoded_form.items()) == [("foo", "bar")]
+ assert list(flow.request.urlencoded_form.items()) == [(b"foo", b"bar")]
def test_modify_querystring():
@@ -119,11 +119,11 @@ def test_modify_response_body():
with example("modify_response_body.py"):
assert True
- flow = tutils.tflow(resp=netutils.tresp(content="I <3 mitmproxy"))
+ flow = tutils.tflow(resp=netutils.tresp(content=b"I <3 mitmproxy"))
with example("modify_response_body.py mitmproxy rocks") as ex:
- assert ex.ctx.old == "mitmproxy" and ex.ctx.new == "rocks"
+ assert ex.ctx.old == b"mitmproxy" and ex.ctx.new == b"rocks"
ex.run("response", flow)
- assert flow.response.content == "I <3 rocks"
+ assert flow.response.content == b"I <3 rocks"
def test_redirect_requests():
diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py
index 33c5137a..e6d65e40 100644
--- a/test/mitmproxy/test_flow_export.py
+++ b/test/mitmproxy/test_flow_export.py
@@ -60,7 +60,7 @@ class TestExportPythonCode():
def test_post_json(self):
p = req_post()
- p.content = '{"name": "example", "email": "example@example.com"}'
+ p.content = b'{"name": "example", "email": "example@example.com"}'
p.headers = Headers(content_type="application/json")
flow = tutils.tflow(req=p)
python_equals("data/test_flow_export/python_post_json.py", export.python_code(flow))
@@ -112,7 +112,7 @@ class TestExportLocustCode():
def test_post(self):
p = req_post()
- p.content = '''content'''
+ p.content = b'content'
p.headers = ''
flow = tutils.tflow(req=p)
python_equals("data/test_flow_export/locust_post.py", export.locust_code(flow))
@@ -142,14 +142,14 @@ class TestIsJson():
def test_json_type(self):
headers = Headers(content_type="application/json")
- assert export.is_json(headers, "foobar") is False
+ assert export.is_json(headers, b"foobar") is False
def test_valid(self):
headers = Headers(content_type="application/foobar")
- j = export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
+ j = export.is_json(headers, b'{"name": "example", "email": "example@example.com"}')
assert j is False
def test_valid2(self):
headers = Headers(content_type="application/json")
- j = export.is_json(headers, '{"name": "example", "email": "example@example.com"}')
+ j = export.is_json(headers, b'{"name": "example", "email": "example@example.com"}')
assert isinstance(j, dict)
diff --git a/test/netlib/http/http1/test_assemble.py b/test/netlib/http/http1/test_assemble.py
index 50d29384..841ea58a 100644
--- a/test/netlib/http/http1/test_assemble.py
+++ b/test/netlib/http/http1/test_assemble.py
@@ -24,7 +24,7 @@ def test_assemble_request():
def test_assemble_request_head():
- c = assemble_request_head(treq(content="foo"))
+ c = assemble_request_head(treq(content=b"foo"))
assert b"GET" in c
assert b"qvalue" in c
assert b"content-length" in c
diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py
index f5bf7f0c..ab2ac628 100644
--- a/test/netlib/http/test_message.py
+++ b/test/netlib/http/test_message.py
@@ -7,8 +7,8 @@ from netlib.tutils import tresp
def _test_passthrough_attr(message, attr):
assert getattr(message, attr) == getattr(message.data, attr)
- setattr(message, attr, "foo")
- assert getattr(message.data, attr) == "foo"
+ setattr(message, attr, b"foo")
+ assert getattr(message.data, attr) == b"foo"
def _test_decoded_attr(message, attr):