def test_tcp_socket_already_taken(self):
     conf = InetStreamSocketConfig('127.0.0.1', 51041)
     sock_manager = self._makeOne(conf)
     sock = sock_manager.get_socket()
     sock_manager2 = self._makeOne(conf)
     self.assertRaises(socket.error, sock_manager2.get_socket)
     del sock
Beispiel #2
0
 def test_tcp_w_hostname(self):
     conf = InetStreamSocketConfig('localhost', 12345)
     sock_manager = self._makeOne(conf)
     self.assertEqual(sock_manager.socket_config, conf)
     sock = sock_manager.get_socket()
     self.assertEqual(sock.getsockname(), ('127.0.0.1', 12345))
     sock_manager.request_close()
Beispiel #3
0
 def test_tcp_socket_already_taken(self):
     conf = InetStreamSocketConfig('127.0.0.1', 12345)
     sock_manager = self._makeOne(conf)
     sock = sock_manager.get_socket()
     sock_manager2 = self._makeOne(conf)
     self.assertRaises(socket.error, sock_manager2.get_socket)
     sock = None
     sock_manager.request_close()
 def test_close_requires_prepared_socket(self):
     conf = InetStreamSocketConfig('127.0.0.1', 51041)
     sock_manager = self._makeOne(conf)
     self.assertFalse(sock_manager.is_prepared())
     try:
         sock_manager._close()
         self.fail()
     except Exception as e:
         self.assertEqual(e.args[0], 'Socket has not been prepared')
 def test_tcp_w_ip(self):
     conf = InetStreamSocketConfig('127.0.0.1', 51041)
     sock_manager = self._makeOne(conf)
     self.assertEqual(sock_manager.socket_config, conf)
     sock = sock_manager.get_socket()
     self.assertEqual(sock.getsockname(), ('127.0.0.1', 51041))