File: test_ssh.py

package info (click to toggle)
jupyter-client 8.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,600 kB
  • sloc: python: 9,025; makefile: 168; sh: 33
file content (18 lines) | stat: -rw-r--r-- 431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import socket

import pytest

from jupyter_client.ssh.tunnel import open_tunnel, select_random_ports


def test_random_ports():
    for _ in range(4096):
        ports = select_random_ports(10)
        assert len(ports) == 10
        for p in ports:
            assert ports.count(p) == 1


def test_open_tunnel():
    with pytest.raises((RuntimeError, socket.error)):
        open_tunnel("tcp://localhost:1234", "does.not.exist")