Esempio n. 1
0
 def test_timeout(self):
     """
     Test a connection that times out and fails.
     """
     with drop_connection(port=self.sock.getsockname()[1]):
         op = TCPConnectOperation(self.test_op, self.sock.getsockname(), 0.01)
         op.callback = op_callback()
         op.start()
         time.sleep(0.01)
         self.test_op.run_selector()
         op.callback.assert_called_once_with(op)
         self.assertIsNone(op.socket)
         self.assertTrue(self.test_op.updated_with("Timed out"))
         self.assertTrue(self.test_op.is_done())
Esempio n. 2
0
 def test_timeout(self):
     """
     Test a handshake that fails because it times out.
     """
     self.start_server()
     sock = self.connect_client()
     with drop_connection(port=self.sock.getsockname()[1]):
         op = SSLHandshakeOperation(self.test_op, sock, 'localhost',
                                    self.certfile, 0.01)
         op.callback = op_callback()
         op.start()
         time.sleep(0.01)
         self.test_op.run_selector()
         op.callback.assert_called_once_with(op)
         self.assertIsNone(op.socket)
         self.assertTrue(self.test_op.updated_with('Timed out'))
         self.assertTrue(self.test_op.is_done())