Beispiel #1
0
async 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):
        await sock.write_readline(IDN_REQ)
    assert not sock.connected()
    assert sock.in_waiting() == 0
    assert sock.connection_counter == 0
Beispiel #2
0
def test_socket_creation():
    sock = TCP("example.com", 34567)
    assert sock.host == "example.com"
    assert sock.port == 34567
    assert sock.connection_timeout is None
    assert sock.timeout is None
    assert sock.auto_reconnect
    assert not sock.connected()
    assert sock.in_waiting() == 0
    assert sock.connection_counter == 0