From e40482576ca5b03f7c65332b8f1409366f7adbd9 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 18 Nov 2012 09:04:49 +1300 Subject: [PATCH] Add disconnect specifiers to test suite. Fixes hangs seen in test suite with recent versions of requetss. --- test/test_app.py | 2 +- test/test_pathod.py | 12 ++++++------ test/test_test.py | 12 ++++++------ test/tutils.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/test_app.py b/test/test_app.py index b31940527..6fc64dbe2 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -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 diff --git a/test/test_pathod.py b/test/test_pathod.py index 46b1fb1d5..70c9a5ecf 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -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 diff --git a/test/test_test.py b/test/test_test.py index 538fc0568..fc97d263d 100644 --- a/test/test_test.py +++ b/test/test_test.py @@ -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) diff --git a/test/tutils.py b/test/tutils.py index 3de18417c..0a5455a3b 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -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,