1#!/usr/bin/env python 2 3from socket import gaierror 4 5 6def test_client_bind_int(): 7 from circuits.net.sockets import Client 8 9 class TestClient(Client): 10 11 def _create_socket(self): 12 return None 13 14 client = TestClient(1234) 15 16 assert client._bind[1] == 1234 17 18 19def test_client_bind_int_gaierror(monkeypatch): 20 from circuits.net import sockets 21 22 def broken_gethostname(): 23 raise gaierror() 24 25 monkeypatch.setattr(sockets, "gethostname", broken_gethostname) 26 27 class TestClient(sockets.Client): 28 29 def _create_socket(self): 30 return None 31 32 client = TestClient(1234) 33 34 assert client._bind == ("0.0.0.0", 1234) 35 36 37def test_client_bind_str(): 38 from circuits.net.sockets import Client 39 40 class TestClient(Client): 41 42 def _create_socket(self): 43 return None 44 45 client = TestClient("0.0.0.0:1234") 46 47 assert client._bind == ("0.0.0.0", 1234) 48