def test_write_readline_fail(unused_tcp_port): sock = TCP("0", unused_tcp_port) assert not sock.connected() assert sock.connection_counter == 0 with pytest.raises(ConnectionRefusedError): sock.write_readline(IDN_REQ) assert not sock.connected() assert sock.connection_counter == 0
def test_open_fail(unused_tcp_port): sock = TCP("0", unused_tcp_port) assert not sock.connected() assert sock.connection_counter == 0 with pytest.raises(ConnectionRefusedError): sock.open() assert not sock.connected() assert sock.connection_counter == 0
def test_socket_creation(): sock = TCP("example.com", 34567) assert sock.host == "example.com" assert sock.port == 34567 assert not sock.connected() assert sock.connection_counter == 0