summaryrefslogtreecommitdiffhomepage
path: root/test/unit.py
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2018-04-26 17:37:24 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2018-04-26 17:37:24 +0300
commitd9f8479375fb6231db26e53a6549f2b96108faee (patch)
tree51f2f782db679cd454260fc7da02db337386e8f2 /test/unit.py
parenta44d358f2949e420dc82b530e07f21ae158f00ae (diff)
downloadunit-d9f8479375fb6231db26e53a6549f2b96108faee.tar.gz
unit-d9f8479375fb6231db26e53a6549f2b96108faee.tar.bz2
Tests: response handling improved.
Diffstat (limited to '')
-rw-r--r--test/unit.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/unit.py b/test/unit.py
index 90906ba8..e1bf2374 100644
--- a/test/unit.py
+++ b/test/unit.py
@@ -259,17 +259,21 @@ class TestUnitHTTP(TestUnit):
return self.http('PUT', **kwargs)
def _recvall(self, sock, buff_size=4096):
- data = ''
+ data = b''
while select.select([sock], [], [], 1)[0]:
- part = sock.recv(buff_size).decode()
+ part = sock.recv(buff_size)
data += part
- if part is '':
+ if not len(part):
break
- return data
+ return data.decode()
def _resp_to_dict(self, resp):
m = re.search('(.*?\x0d\x0a?)\x0d\x0a?(.*)', resp, re.M | re.S)
+
+ if not m:
+ return {}
+
headers_text, body = m.group(1), m.group(2)
p = re.compile('(.*?)\x0d\x0a?', re.M | re.S)