mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-26 17:14:42 +00:00
Make test_telnet.py fast
Linkchecker's telnet://username:password@host:port URL verification logic is - connect to host:port - wait for 'login: ' to appear (with a 10 second timeout), send username - wait for 'Password: ' to appear (with a 10 second timeout), send password The test spawns a fake telnet server on localhost that never presented the login/password prompts, forcing the 10 second timeout three times. This commit makes the fake telnet server emit the expected prompts, making the test pass in .2 seconds.
This commit is contained in:
parent
3a7c2a9823
commit
947b108f9e
1 changed files with 3 additions and 1 deletions
|
|
@ -65,7 +65,7 @@ def start_server (host, port, stop_event):
|
|||
clients = []
|
||||
def on_connect(client):
|
||||
clients.append(client)
|
||||
client.send("Telnet test server\n")
|
||||
client.send("Telnet test server\nlogin: ")
|
||||
server = miniboa.TelnetServer(port=port, address=host, on_connect=on_connect)
|
||||
port = server.server_socket.getsockname()[1]
|
||||
t = threading.Thread(None, serve_forever, args=(server, clients, stop_event))
|
||||
|
|
@ -100,3 +100,5 @@ def handle_cmd(client):
|
|||
msg = client.get_command().lower()
|
||||
if msg == 'exit':
|
||||
client.active = False
|
||||
else:
|
||||
client.send("Password: ")
|
||||
|
|
|
|||
Loading…
Reference in a new issue