I have ThreadedSimpleServer. Now I want to test it with unittest. In test.py file I have class Test(unittest.TestCase).
if __name__ == '__main__':
# create service
service = Service()
# run service in a separate thread
thread = Thread(target=service.start, name='ServiceThread')
thread.start()
# start testing
unittest.main()
When I run code, broken pipe error is occur on one of the test:
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 693, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
If I run server from one place, and execute unittest from another, there is no error. Connection is open on the both side during the entire time. Where is the problem?