From 813f7c9de67e58685a28be9845498c61478b3ada Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Wed, 24 Apr 2013 14:01:56 -0700 Subject: [PATCH] Make it easier to debug badly broken tests. If you manage to break a proxy server so badly that it can't even return headers, then in test/unit/proxy/test_server.py, readuntil2crlfs() will spin forever, killing your laptop battery and providing zero help figuring out what's wrong. This test-only change makes it so that, should readuntil2crlfs() run out of data before getting its two CRLFs, it raises an exception that tells you what it did manage to get, and does so in a finite amount of time. Change-Id: Ieacd18ce7f4d35a4960100d5fc3a0f910cb406ac --- test/unit/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 9d3577276d..18e80844fd 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -24,6 +24,8 @@ def readuntil2crlfs(fd): crlfs = 0 while crlfs < 2: c = fd.read(1) + if not c: + raise ValueError("didn't get two CRLFs; just got %r" % rv) rv = rv + c if c == '\r' and lc != '\n': crlfs = 0