diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2019-02-27 19:43:14 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2019-02-27 19:43:14 +0300 |
commit | bd77c9a4d2b0f6f609e033060a5486c0afe6b19e (patch) | |
tree | 2a8c4475f96d5a8195451728318e68c67a5c4fb6 /test/unit.py | |
parent | 4de2c8b56719fce6b95b6f8a613b349590a3676f (diff) | |
download | unit-bd77c9a4d2b0f6f609e033060a5486c0afe6b19e.tar.gz unit-bd77c9a4d2b0f6f609e033060a5486c0afe6b19e.tar.bz2 |
Tests: read_timeout option introduced.
Also, increased default select() timeout from 1s to 5s.
Diffstat (limited to 'test/unit.py')
-rw-r--r-- | test/unit.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/unit.py b/test/unit.py index 80e26e0d..7a51eb20 100644 --- a/test/unit.py +++ b/test/unit.py @@ -357,7 +357,8 @@ class TestUnitHTTP(TestUnit): if 'no_recv' not in kwargs: enc = 'utf-8' if 'encoding' not in kwargs else kwargs['encoding'] - resp = self.recvall(sock).decode(enc) + read_timeout = 5 if 'read_timeout' not in kwargs else kwargs['read_timeout'] + resp = self.recvall(sock, read_timeout=read_timeout).decode(enc) if TestUnit.detailed: print('<<<', resp.encode('utf-8'), sep='\n') @@ -383,9 +384,9 @@ class TestUnitHTTP(TestUnit): def put(self, **kwargs): return self.http('PUT', **kwargs) - def recvall(self, sock, buff_size=4096): + def recvall(self, sock, read_timeout=5, buff_size=4096): data = b'' - while select.select([sock], [], [], 1)[0]: + while select.select([sock], [], [], read_timeout)[0]: try: part = sock.recv(buff_size) except: |