tests/test_ssh.py
raw| 1 | import socket |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | from jupyter_client.ssh.tunnel import open_tunnel, select_random_ports |
| 6 | |
| 7 | |
| 8 | def test_random_ports(): |
| 9 | for _ in range(4096): |
| 10 | ports = select_random_ports(10) |
| 11 | assert len(ports) == 10 |
| 12 | for p in ports: |
| 13 | assert ports.count(p) == 1 |
| 14 | |
| 15 | |
| 16 | def test_open_tunnel(): |
| 17 | with pytest.raises((RuntimeError, socket.error)): |
| 18 | open_tunnel("tcp://localhost:1234", "does.not.exist") |