diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2021-04-05 14:03:05 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2021-04-05 14:03:05 +0100 |
commit | 6c97a1a069f0ae8cf683c8364fb7f9dabc5e89cb (patch) | |
tree | a7eab02b6fc63ff8d1a1329a090162715371aa62 /test/unit/http.py | |
parent | 46d8567dd7c2a9af025f1de13084a9efd7118e20 (diff) | |
download | unit-6c97a1a069f0ae8cf683c8364fb7f9dabc5e89cb.tar.gz unit-6c97a1a069f0ae8cf683c8364fb7f9dabc5e89cb.tar.bz2 |
Tests: style.
Diffstat (limited to 'test/unit/http.py')
-rw-r--r-- | test/unit/http.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/test/unit/http.py b/test/unit/http.py index 7706fe05..797b7681 100644 --- a/test/unit/http.py +++ b/test/unit/http.py @@ -10,15 +10,16 @@ import pytest from unit.option import option -class TestHTTP(): +class TestHTTP: def http(self, start_str, **kwargs): sock_type = kwargs.get('sock_type', 'ipv4') port = kwargs.get('port', 7080) url = kwargs.get('url', '/') http = 'HTTP/1.0' if 'http_10' in kwargs else 'HTTP/1.1' - headers = kwargs.get('headers', - {'Host': 'localhost', 'Connection': 'close'}) + headers = kwargs.get( + 'headers', {'Host': 'localhost', 'Connection': 'close'} + ) body = kwargs.get('body', b'') crlf = '\r\n' @@ -305,8 +306,9 @@ class TestHTTP(): return body, content_type def form_url_encode(self, fields): - data = "&".join("%s=%s" % (name, value) - for name, value in fields.items()).encode() + data = "&".join( + "%s=%s" % (name, value) for name, value in fields.items() + ).encode() return data, 'application/x-www-form-urlencoded' def multipart_encode(self, fields): @@ -326,7 +328,9 @@ class TestHTTP(): datatype = value['type'] if not isinstance(value['data'], io.IOBase): - pytest.fail('multipart encoding of file requires a stream.') + pytest.fail( + 'multipart encoding of file requires a stream.' + ) data = value['data'].read() @@ -336,9 +340,10 @@ class TestHTTP(): else: pytest.fail('multipart requires a string or stream data') - body += ( - "--%s\r\nContent-Disposition: form-data; name=\"%s\"" - ) % (boundary, field) + body += ("--%s\r\nContent-Disposition: form-data; name=\"%s\"") % ( + boundary, + field, + ) if filename != '': body += "; filename=\"%s\"" % filename |