summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2017-11-29 15:23:22 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2017-11-29 15:23:22 +0300
commitec4ad8780e0afd7416c7ba7c32a1936e646cc286 (patch)
tree4825ce26e47b3dc727708b48acb42a6c3bc497ab /test
parent75198f82b12bde2220baeacd37bd2e665833d984 (diff)
downloadunit-ec4ad8780e0afd7416c7ba7c32a1936e646cc286.tar.gz
unit-ec4ad8780e0afd7416c7ba7c32a1936e646cc286.tar.bz2
Tests: "verbose" mode introduced.
Diffstat (limited to '')
-rw-r--r--test/unit.py52
1 files changed, 39 insertions, 13 deletions
diff --git a/test/unit.py b/test/unit.py
index 4b9c8531..3ed7b495 100644
--- a/test/unit.py
+++ b/test/unit.py
@@ -82,20 +82,38 @@ class TestUnitControl(TestUnit):
def get(self, path='/'):
with self._control_sock() as sock:
- sock.sendall(('GET ' + path
- + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode())
- r = self._recvall(sock)
+ req = ('GET ' + path
+ + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode()
- return self._body_json(r)
+ sock.sendall(req)
+
+ if '--verbose' in sys.argv:
+ print('>>>\n', req)
+
+ resp = self._recvall(sock)
+
+ if '--verbose' in sys.argv:
+ print('<<<\n', resp)
+
+ return self._body_json(resp)
def delete(self, path='/'):
with self._control_sock() as sock:
- sock.sendall(('DELETE ' + path
- + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode())
- r = self._recvall(sock)
+ req = ('DELETE ' + path
+ + ' HTTP/1.1\r\nHost: localhost\r\n\r\n').encode()
+
+ sock.sendall(req)
+
+ if '--verbose' in sys.argv:
+ print('>>>\n', req)
- return self._body_json(r)
+ resp = self._recvall(sock)
+
+ if '--verbose' in sys.argv:
+ print('<<<\n', resp)
+
+ return self._body_json(resp)
def put(self, path='/', data=''):
@@ -103,12 +121,20 @@ class TestUnitControl(TestUnit):
data = data.encode()
with self._control_sock() as sock:
- sock.sendall(('PUT ' + path + (' HTTP/1.1\nHost: localhost\n'
- 'Content-Length: ') + str(len(data)) + '\r\n\r\n').encode()
- + data)
- r = self._recvall(sock)
+ req = ('PUT ' + path + (' HTTP/1.1\nHost: localhost\n'
+ 'Content-Length: ') + str(len(data)) + '\r\n\r\n').encode() + data
+
+ sock.sendall(req)
+
+ if '--verbose' in sys.argv:
+ print('>>>\n', req)
+
+ resp = self._recvall(sock)
+
+ if '--verbose' in sys.argv:
+ print('<<<\n', resp)
- return self._body_json(r)
+ return self._body_json(resp)
def _control_sock(self):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)