mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Add disconnect specifiers to test suite.
Fixes hangs seen in test suite with recent versions of requetss.
This commit is contained in:
parent
b11260f064
commit
e40482576c
@ -24,7 +24,7 @@ class TestApp(tutils.DaemonTests):
|
||||
|
||||
def test_log(self):
|
||||
assert self.getpath("/log").status_code == 200
|
||||
assert self.get("200").status_code == 200
|
||||
assert self.get("200:da").status_code == 200
|
||||
id = self.d.log()[0]["id"]
|
||||
assert self.getpath("/log").status_code == 200
|
||||
assert self.getpath("/log/%s"%id).status_code == 200
|
||||
|
@ -7,10 +7,10 @@ class TestPathod:
|
||||
def test_instantiation(self):
|
||||
p = pathod.Pathod(
|
||||
("127.0.0.1", 0),
|
||||
anchors = [(".*", "200")]
|
||||
anchors = [(".*", "200:da")]
|
||||
)
|
||||
assert p.anchors
|
||||
tutils.raises("invalid regex", pathod.Pathod, ("127.0.0.1", 0), anchors=[("*", "200")])
|
||||
tutils.raises("invalid regex", pathod.Pathod, ("127.0.0.1", 0), anchors=[("*", "200:da")])
|
||||
tutils.raises("invalid page spec", pathod.Pathod, ("127.0.0.1", 0), anchors=[("foo", "bar")])
|
||||
|
||||
def test_logging(self):
|
||||
@ -30,16 +30,16 @@ class TestPathod:
|
||||
class TestNoWeb(tutils.DaemonTests):
|
||||
noweb = True
|
||||
def test_noweb(self):
|
||||
assert self.get("200").status_code == 200
|
||||
assert self.get("200:da").status_code == 200
|
||||
assert self.getpath("/").status_code == 800
|
||||
|
||||
|
||||
class TestTimeout(tutils.DaemonTests):
|
||||
timeout = 0.001
|
||||
timeout = 0.00001
|
||||
def test_noweb(self):
|
||||
# FIXME: Add float values to spec language, reduce test timeout to
|
||||
# increase test performance
|
||||
assert self.get("200:p1,1").status_code == 200
|
||||
assert self.get("200:p1,2").status_code == 200
|
||||
assert self.d.last_log()["type"] == "timeout"
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ class CommonTests(tutils.DaemonTests):
|
||||
def test_logs(self):
|
||||
assert self.d.clear_log()
|
||||
tutils.raises("no requests logged", self.d.last_log)
|
||||
rsp = self.get("202")
|
||||
rsp = self.get("202:da")
|
||||
assert len(self.d.log()) == 1
|
||||
assert self.d.clear_log()
|
||||
assert len(self.d.log()) == 0
|
||||
|
@ -8,18 +8,18 @@ logging.disable(logging.CRITICAL)
|
||||
class TestDaemonManual:
|
||||
def test_simple(self):
|
||||
with test.Daemon() as d:
|
||||
rsp = requests.get("http://localhost:%s/p/202"%d.port)
|
||||
rsp = requests.get("http://localhost:%s/p/202:da"%d.port)
|
||||
assert rsp.ok
|
||||
assert rsp.status_code == 202
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202"%d.port)
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202:da"%d.port)
|
||||
|
||||
def test_startstop_ssl(self):
|
||||
d = test.Daemon(ssl=True)
|
||||
rsp = requests.get("https://localhost:%s/p/202"%d.port, verify=False)
|
||||
rsp = requests.get("https://localhost:%s/p/202:da"%d.port, verify=False)
|
||||
assert rsp.ok
|
||||
assert rsp.status_code == 202
|
||||
d.shutdown()
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202"%d.port)
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202:da"%d.port)
|
||||
|
||||
def test_startstop_ssl_explicit(self):
|
||||
ssloptions = dict(
|
||||
@ -27,10 +27,10 @@ class TestDaemonManual:
|
||||
certfile = utils.data.path("resources/server.crt"),
|
||||
)
|
||||
d = test.Daemon(ssl=ssloptions)
|
||||
rsp = requests.get("https://localhost:%s/p/202"%d.port, verify=False)
|
||||
rsp = requests.get("https://localhost:%s/p/202:da"%d.port, verify=False)
|
||||
assert rsp.ok
|
||||
assert rsp.status_code == 202
|
||||
d.shutdown()
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202"%d.port)
|
||||
tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202:da"%d.port)
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ class DaemonTests:
|
||||
def setUpAll(self):
|
||||
self.d = test.Daemon(
|
||||
staticdir=test_data.path("data"),
|
||||
anchors=[("/anchor/.*", "202")],
|
||||
anchors=[("/anchor/.*", "202:da")],
|
||||
ssl = self.ssl,
|
||||
sizelimit=1*1024*1024,
|
||||
noweb = self.noweb,
|
||||
|
Loading…
Reference in New Issue
Block a user