diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2017-02-02 17:23:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 17:23:11 +0100 |
commit | 3f4d472c80f707b3ffbc060123d811c6bcae2afd (patch) | |
tree | 465ed866617e3d613078f1a682ff4eb5018c43f1 /test/pathod/test_pathod.py | |
parent | c1bc1ea584d4bb47c1b754dfa7f10ab4dfc380a3 (diff) | |
parent | 4f0b2bc4dec4eb3c4f0075bcebebeb126a5a6e88 (diff) | |
download | mitmproxy-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_pathod.py')
-rw-r--r-- | test/pathod/test_pathod.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 1e34af23..60ac8072 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -36,7 +36,8 @@ class TestTimeout(tservers.DaemonTests): # increase test performance # This is a bodge - we have some platform difference that causes # different exceptions to be raised here. - tutils.raises(Exception, self.pathoc, ["get:/:p1,1"]) + with pytest.raises(Exception): + self.pathoc(["get:/:p1,1"]) assert self.d.last_log()["type"] == "timeout" @@ -133,7 +134,8 @@ class CommonTests(tservers.DaemonTests): assert len(self.d.log()) == 0 def test_disconnect(self): - tutils.raises("unexpected eof", self.get, "202:b@100k:d200") + with pytest.raises("unexpected eof"): + self.get("202:b@100k:d200") def test_parserr(self): rsp = self.get("400:msg,b:") @@ -160,17 +162,15 @@ class CommonTests(tservers.DaemonTests): assert "foo" in l["msg"] def test_invalid_content_length(self): - tutils.raises( - exceptions.HttpException, - self.pathoc, - ["get:/:h'content-length'='foo'"] - ) + with pytest.raises(exceptions.HttpException): + self.pathoc(["get:/:h'content-length'='foo'"]) l = self.d.last_log() assert l["type"] == "error" assert "Unparseable Content Length" in l["msg"] def test_invalid_headers(self): - tutils.raises(exceptions.HttpException, self.pathoc, ["get:/:h'\t'='foo'"]) + with pytest.raises(exceptions.HttpException): + self.pathoc(["get:/:h'\t'='foo'"]) l = self.d.last_log() assert l["type"] == "error" assert "Invalid headers" in l["msg"] @@ -228,12 +228,8 @@ class TestDaemon(CommonTests): assert r[0].status_code == 202 def test_connect_err(self): - tutils.raises( - exceptions.HttpException, - self.pathoc, - [r"get:'http://foo.com/p/202':da"], - connect_to=("localhost", self.d.port) - ) + with pytest.raises(exceptions.HttpException): + self.pathoc([r"get:'http://foo.com/p/202':da"], connect_to=("localhost", self.d.port)) class TestDaemonSSL(CommonTests): @@ -245,7 +241,8 @@ class TestDaemonSSL(CommonTests): c.wbufsize = 0 with c.connect(): c.wfile.write(b"\0\0\0\0") - tutils.raises(exceptions.TlsException, c.convert_to_ssl) + with pytest.raises(exceptions.TlsException): + c.convert_to_ssl() l = self.d.last_log() assert l["type"] == "error" assert "SSL" in l["msg"] |