aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-06-07 12:09:30 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-06-08 16:15:54 +0530
commitb3b4156c2f50ae81f1c1e4c750e47572127baecd (patch)
tree1058806b010f0b4dbf12a050eae47a714184e74d
parent6b03df2633c4e82dac378cb2d0d5506067c6f40c (diff)
downloadmitmproxy-b3b4156c2f50ae81f1c1e4c750e47572127baecd.tar.gz
mitmproxy-b3b4156c2f50ae81f1c1e4c750e47572127baecd.tar.bz2
mitmproxy-b3b4156c2f50ae81f1c1e4c750e47572127baecd.zip
Py3: Fix test_language_http2 tests by using byte literals
-rw-r--r--test/pathod/test_language_http2.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/test/pathod/test_language_http2.py b/test/pathod/test_language_http2.py
index 40243f03..a2bffe63 100644
--- a/test/pathod/test_language_http2.py
+++ b/test/pathod/test_language_http2.py
@@ -46,15 +46,15 @@ class TestRequest:
def test_simple(self):
r = parse_request('GET:"/foo"')
- assert r.method.string() == "GET"
- assert r.path.string() == "/foo"
+ assert r.method.string() == b"GET"
+ assert r.path.string() == b"/foo"
r = parse_request('GET:/foo')
- assert r.path.string() == "/foo"
+ assert r.path.string() == b"/foo"
def test_multiple(self):
r = list(language.parse_pathoc("GET:/ PUT:/"))
- assert r[0].method.string() == "GET"
- assert r[1].method.string() == "PUT"
+ assert r[0].method.string() == b"GET"
+ assert r[1].method.string() == b"PUT"
assert len(r) == 2
l = """
@@ -71,8 +71,8 @@ class TestRequest:
"""
r = list(language.parse_pathoc(l, True))
assert len(r) == 2
- assert r[0].method.string() == "GET"
- assert r[1].method.string() == "PUT"
+ assert r[0].method.string() == b"GET"
+ assert r[1].method.string() == b"PUT"
l = """
get:"http://localhost:9999/p/200"
@@ -80,8 +80,8 @@ class TestRequest:
"""
r = list(language.parse_pathoc(l, True))
assert len(r) == 2
- assert r[0].method.string() == "GET"
- assert r[1].method.string() == "GET"
+ assert r[0].method.string() == b"GET"
+ assert r[1].method.string() == b"GET"
def test_render_simple(self):
s = BytesIO()
@@ -101,29 +101,29 @@ class TestRequest:
r = parse_request('GET:/')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-length", "0")
+ assert r.headers[0].values(default_settings()) == (b"content-length", b"0")
r = parse_request('GET:/:b"foobar"')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-length", "6")
+ assert r.headers[0].values(default_settings()) == (b"content-length", b"6")
r = parse_request('GET:/:b"foobar":h"content-length"="42"')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-length", "42")
+ assert r.headers[0].values(default_settings()) == (b"content-length", b"42")
r = parse_request('GET:/:r:b"foobar":h"content-length"="42"')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-length", "42")
+ assert r.headers[0].values(default_settings()) == (b"content-length", b"42")
def test_content_type(self):
r = parse_request('GET:/:r:c"foobar"')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-type", "foobar")
+ assert r.headers[0].values(default_settings()) == (b"content-type", b"foobar")
def test_user_agent(self):
r = parse_request('GET:/:r:ua')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("user-agent", user_agents.get_by_shortcut('a')[2])
+ assert r.headers[0].values(default_settings()) == (b"user-agent", user_agents.get_by_shortcut('a')[2].encode())
def test_render_with_headers(self):
s = BytesIO()
@@ -177,26 +177,26 @@ class TestResponse:
r = parse_response('200')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-length", "0")
+ assert r.headers[0].values(default_settings()) == (b"content-length", b"0")
def test_content_type(self):
r = parse_response('200:r:c"foobar"')
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("content-type", "foobar")
+ assert r.headers[0].values(default_settings()) == (b"content-type", b"foobar")
def test_simple(self):
r = parse_response('200:r:h"foo"="bar"')
- assert r.status_code.string() == "200"
+ assert r.status_code.string() == b"200"
assert len(r.headers) == 1
- assert r.headers[0].values(default_settings()) == ("foo", "bar")
+ assert r.headers[0].values(default_settings()) == (b"foo", b"bar")
assert r.body is None
r = parse_response('200:r:h"foo"="bar":bfoobar:h"bla"="fasel"')
- assert r.status_code.string() == "200"
+ assert r.status_code.string() == b"200"
assert len(r.headers) == 2
- assert r.headers[0].values(default_settings()) == ("foo", "bar")
- assert r.headers[1].values(default_settings()) == ("bla", "fasel")
- assert r.body.string() == "foobar"
+ assert r.headers[0].values(default_settings()) == (b"foo", b"bar")
+ assert r.headers[1].values(default_settings()) == (b"bla", b"fasel")
+ assert r.body.string() == b"foobar"
def test_render_simple(self):
s = BytesIO()