Fixed style issues

This commit is contained in:
Braulio Valdivielso Martínez
2016-03-04 19:33:58 +01:00
parent bf026e3c31
commit 0d1a779030
+7 -13
View File
@@ -1,10 +1,7 @@
#!/usr/bin/python
import threading
import socket
import select
def consume_socket_content(sock, timeout=0.5):
chunks = 65536
content = ""
@@ -17,19 +14,17 @@ def consume_socket_content(sock, timeout=0.5):
break
content += new_content
# stop reading if no new data is received for a while
# stop reading if no new data is received for a while
more_to_read = select.select([sock], [], [], timeout)[0]
return content
class Server(threading.Thread):
""" Dummy server using for unit testing """
"""Dummy server using for unit testing"""
WAIT_EVENT_TIMEOUT = 5
def __init__(self, handler, host='localhost', port=0, requests_to_handle=1, wait_to_close_event=None):
threading.Thread.__init__(self)
super(Server, self).__init__()
self.handler = handler
self.handler_results = []
@@ -51,16 +46,15 @@ class Server(threading.Thread):
return request_content
server = Server(text_response_handler, **kwargs)
return server
return Server(text_response_handler, **kwargs)
@classmethod
def basic_response_server(cls, **kwargs):
server = cls.text_response_server(
return cls.text_response_server(
"HTTP/1.1 200 OK\r\n" +
"Content-Length: 0\r\n\r\n", **kwargs
"Content-Length: 0\r\n\r\n",
**kwargs
)
return server
def run(self):
try: