Exemplo n.º 1
0
 def test_bad_request(self):
     address = ('127.0.0.1', 9099)
     client = Echo()
     try:
         result = yield client.request(address, b'Hello!')
     except socket.error as e:
         pass
     self.assertEqual(len(client.connection_pools), 1)
Exemplo n.º 2
0
 def test_bad_request(self):
     address = ('127.0.0.1', 9099)
     client = Echo()
     try:
         result = yield client.request(address, b'Hello!')
     except socket.error as e:
         pass
     self.assertEqual(len(client.connection_pools), 1)
Exemplo n.º 3
0
 def test_echo_serve(self):
     loop = get_event_loop()
     server = TcpServer(loop, '127.0.0.1', 0, EchoServerProtocol)
     yield server.start_serving()
     sock = server.sock
     fn = sock.fileno()
     self.assertFalse(is_socket_closed(sock))
     client = Echo()
     address = sock.getsockname()
     result = yield client.request(address, b'Hello!')
     self.assertEqual(result, b'Hello!')
     self.assertEqual(server.concurrent_connections, 1)
     result = yield client.request(address, b'ciao')
     self.assertEqual(result, b'ciao')
     self.assertEqual(server.concurrent_connections, 1)
     yield server.stop_serving()
     yield async_while(3, lambda: not is_socket_closed(sock))
     self.assertTrue(is_socket_closed(sock))