Exemple #1
0
def test_open_failure():
    conn = TelnetTransport("localhost", port=23)
    with pytest.raises(ConnectionNotOpened) as exc:
        conn.open()
    assert str(
        exc.value
    ) == "Failed to open telnet session to host localhost, connection refused"
Exemple #2
0
def test_requires_open(method_name):
    conn = TelnetTransport("localhost")
    method = getattr(conn, method_name)
    with pytest.raises(ConnectionNotOpened):
        if method_name == "write":
            method("blah")
        else:
            method()
Exemple #3
0
def test_keepalive_standard():
    conn = TelnetTransport("localhost")
    with pytest.raises(NotImplementedError) as exc:
        conn._keepalive_standard()
    assert str(exc.value) == "No 'standard' keepalive mechanism for telnet."
Exemple #4
0
def test_creation():
    conn = TelnetTransport("localhost")
    assert conn.host == "localhost"
    assert conn.port == 23
    assert conn._isauthenticated is False