psutil.tests.test_connections

Tests for net_connections() and Process.connections() APIs.

Module Contents

thisproc
class Base

Bases:object

setUp(self)
tearDown(self)
get_conn_from_sock(self, sock)
check_socket(self, sock, conn=None)

Given a socket, makes sure it matches the one obtained via psutil. It assumes this process created one connection only (the one supposed to be checked).

compare_procsys_connections(self, pid, proc_cons, kind='all')

Given a process PID and its list of connections compare those against system-wide connections retrieved via psutil.net_connections.

class TestUnconnectedSockets

Bases:psutil.tests.test_connections.Base, psutil.tests.unittest.TestCase

Tests sockets which are open but not connected to anything.

test_tcp_v4(self)
test_tcp_v6(self)
test_udp_v4(self)
test_udp_v6(self)
test_unix_tcp(self)
test_unix_udp(self)
class TestConnectedSocketPairs

Bases:psutil.tests.test_connections.Base, psutil.tests.unittest.TestCase

Test socket pairs which are are actually connected to each other.

test_tcp(self)
test_unix(self)
test_combos(self)
test_multi_sockets_filtering(self)
class TestSystemWideConnections

Bases:psutil.tests.test_connections.Base, psutil.tests.unittest.TestCase

Tests for net_connections().

test_it(self)
test_multi_socks(self)
test_multi_sockets_procs(self)
class TestMisc

Bases:psutil.tests.unittest.TestCase

test_connection_constants(self)