aboutsummaryrefslogtreecommitdiffstats
path: root/test/pathod/test_language_http.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-02-02 17:23:11 +0100
committerGitHub <noreply@github.com>2017-02-02 17:23:11 +0100
commit3f4d472c80f707b3ffbc060123d811c6bcae2afd (patch)
tree465ed866617e3d613078f1a682ff4eb5018c43f1 /test/pathod/test_language_http.py
parentc1bc1ea584d4bb47c1b754dfa7f10ab4dfc380a3 (diff)
parent4f0b2bc4dec4eb3c4f0075bcebebeb126a5a6e88 (diff)
downloadmitmproxy-3f4d472c80f707b3ffbc060123d811c6bcae2afd.tar.gz
mitmproxy-3f4d472c80f707b3ffbc060123d811c6bcae2afd.tar.bz2
mitmproxy-3f4d472c80f707b3ffbc060123d811c6bcae2afd.zip
Merge pull request #1980 from Kriechi/improve-tests
improve tests
Diffstat (limited to 'test/pathod/test_language_http.py')
-rw-r--r--test/pathod/test_language_http.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/test/pathod/test_language_http.py b/test/pathod/test_language_http.py
index 9a239bf5..199fdf64 100644
--- a/test/pathod/test_language_http.py
+++ b/test/pathod/test_language_http.py
@@ -1,8 +1,9 @@
import io
+import pytest
+
from pathod import language
from pathod.language import http, base
-from mitmproxy.test import tutils
from . import tservers
@@ -19,10 +20,12 @@ def test_make_error_response():
class TestRequest:
def test_nonascii(self):
- tutils.raises("ascii", parse_request, "get:\xf0")
+ with pytest.raises("ascii"):
+ parse_request("get:\xf0")
def test_err(self):
- tutils.raises(language.ParseException, parse_request, 'GET')
+ with pytest.raises(language.ParseException):
+ parse_request('GET')
def test_simple(self):
r = parse_request('GET:"/foo"')
@@ -214,9 +217,8 @@ class TestResponse:
testlen(r)
def test_parse_err(self):
- tutils.raises(
- language.ParseException, language.parse_pathod, "400:msg,b:"
- )
+ with pytest.raises(language.ParseException):
+ language.parse_pathod("400:msg,b:")
try:
language.parse_pathod("400'msg':b:")
except language.ParseException as v:
@@ -224,7 +226,8 @@ class TestResponse:
assert str(v)
def test_nonascii(self):
- tutils.raises("ascii", language.parse_pathod, "foo:b\xf0")
+ with pytest.raises("ascii"):
+ language.parse_pathod("foo:b\xf0")
def test_parse_header(self):
r = next(language.parse_pathod('400:h"foo"="bar"'))
@@ -260,7 +263,8 @@ class TestResponse:
def test_websockets(self):
r = next(language.parse_pathod("ws"))
- tutils.raises("no websocket key", r.resolve, language.Settings())
+ with pytest.raises("no websocket key"):
+ r.resolve(language.Settings())
res = r.resolve(language.Settings(websocket_key=b"foo"))
assert res.status_code.string() == b"101"
@@ -327,11 +331,8 @@ def test_nested_response():
e = http.NestedResponse.expr()
v = e.parseString("s'200'")[0]
assert v.value.val == b"200"
- tutils.raises(
- language.ParseException,
- e.parseString,
- "s'foo'"
- )
+ with pytest.raises(language.ParseException):
+ e.parseString("s'foo'")
v = e.parseString('s"200:b@1"')[0]
assert "@1" in v.spec()
@@ -350,8 +351,5 @@ def test_nested_response_freeze():
def test_unique_components():
- tutils.raises(
- "multiple body clauses",
- language.parse_pathod,
- "400:b@1:b@1"
- )
+ with pytest.raises("multiple body clauses"):
+ language.parse_pathod("400:b@1:b@1")