Tests: using dict.get() method with default value.
No functional changes. Only code readability improved.
This commit is contained in:
@@ -14,20 +14,15 @@ from conftest import option
|
|||||||
|
|
||||||
class TestHTTP(TestUnit):
|
class TestHTTP(TestUnit):
|
||||||
def http(self, start_str, **kwargs):
|
def http(self, start_str, **kwargs):
|
||||||
sock_type = (
|
sock_type = kwargs.get('sock_type', 'ipv4')
|
||||||
'ipv4' if 'sock_type' not in kwargs else kwargs['sock_type']
|
port = kwargs.get('port', 7080)
|
||||||
)
|
url = kwargs.get('url', '/')
|
||||||
port = 7080 if 'port' not in kwargs else kwargs['port']
|
|
||||||
url = '/' if 'url' not in kwargs else kwargs['url']
|
|
||||||
http = 'HTTP/1.0' if 'http_10' in kwargs else 'HTTP/1.1'
|
http = 'HTTP/1.0' if 'http_10' in kwargs else 'HTTP/1.1'
|
||||||
|
|
||||||
headers = (
|
headers = kwargs.get('headers',
|
||||||
{'Host': 'localhost', 'Connection': 'close'}
|
{'Host': 'localhost', 'Connection': 'close'})
|
||||||
if 'headers' not in kwargs
|
|
||||||
else kwargs['headers']
|
|
||||||
)
|
|
||||||
|
|
||||||
body = b'' if 'body' not in kwargs else kwargs['body']
|
body = kwargs.get('body', b'')
|
||||||
crlf = '\r\n'
|
crlf = '\r\n'
|
||||||
|
|
||||||
if 'addr' not in kwargs:
|
if 'addr' not in kwargs:
|
||||||
@@ -92,7 +87,7 @@ class TestHTTP(TestUnit):
|
|||||||
|
|
||||||
sock.sendall(req)
|
sock.sendall(req)
|
||||||
|
|
||||||
encoding = 'utf-8' if 'encoding' not in kwargs else kwargs['encoding']
|
encoding = kwargs.get('encoding', 'utf-8')
|
||||||
|
|
||||||
self.log_out(req, encoding)
|
self.log_out(req, encoding)
|
||||||
|
|
||||||
@@ -178,12 +173,8 @@ class TestHTTP(TestUnit):
|
|||||||
def recvall(self, sock, **kwargs):
|
def recvall(self, sock, **kwargs):
|
||||||
timeout_default = 60
|
timeout_default = 60
|
||||||
|
|
||||||
timeout = (
|
timeout = kwargs.get('read_timeout', timeout_default)
|
||||||
timeout_default
|
buff_size = kwargs.get('buff_size', 4096)
|
||||||
if 'read_timeout' not in kwargs
|
|
||||||
else kwargs['read_timeout']
|
|
||||||
)
|
|
||||||
buff_size = 4096 if 'buff_size' not in kwargs else kwargs['buff_size']
|
|
||||||
|
|
||||||
data = b''
|
data = b''
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user