psutil.tests.test_linux

Linux specific tests.

Module Contents

HERE
SIOCGIFADDR = 35093
SIOCGIFCONF = 35090
SIOCGIFHWADDR = 35111
SECTOR_SIZE = 512
get_ipv4_address(ifname)
get_mac_address(ifname)
free_swap()

Parse ‘free’ cmd and return swap memory’s s total, used and free values.

free_physmem()

Parse ‘free’ cmd and return physical memory’s total, used and free values.

vmstat(stat)
get_free_version_info()
mock_open_content(for_path, content)

Mock open() builtin and forces it to return a certain content on read() if the path being opened matches for_path.

mock_open_exception(for_path, exc)

Mock open() builtin and raises exc if the path being opened matches for_path.

class TestSystemVirtualMemory

Bases:psutil.tests.unittest.TestCase

test_total(self)
test_used(self)
test_free(self)
test_buffers(self)
test_active(self)
test_inactive(self)
test_shared(self)
test_available(self)
test_warnings_on_misses(self)
test_avail_old_percent(self)
test_avail_old_comes_from_kernel(self)
test_avail_old_missing_fields(self)
test_avail_old_missing_zoneinfo(self)
test_virtual_memory_mocked(self)
class TestSystemSwapMemory

Bases:psutil.tests.unittest.TestCase

static meminfo_has_swap_info()

Return True if /proc/meminfo provides swap metrics.

test_total(self)
test_used(self)
test_free(self)
test_missing_sin_sout(self)
test_no_vmstat_mocked(self)
test_meminfo_against_sysinfo(self)
test_emulate_meminfo_has_no_metrics(self)
class TestSystemCPU

Bases:psutil.tests.unittest.TestCase

test_cpu_times(self)
test_cpu_count_logical_w_sysdev_cpu_online(self)
test_cpu_count_logical_w_sysdev_cpu_num(self)
test_cpu_count_logical_w_nproc(self)
test_cpu_count_logical_w_lscpu(self)
test_cpu_count_physical_w_lscpu(self)
test_cpu_count_logical_mocked(self)
test_cpu_count_physical_mocked(self)
test_cpu_freq_no_result(self)
test_cpu_freq_use_second_file(self)
test_cpu_freq_use_cpuinfo(self)
test_cpu_freq_emulate_data(self)
test_cpu_freq_emulate_multi_cpu(self)
test_cpu_freq_no_scaling_cur_freq_file(self)
class TestSystemCPUStats

Bases:psutil.tests.unittest.TestCase

test_ctx_switches(self)
test_interrupts(self)
class TestSystemNetwork

Bases:psutil.tests.unittest.TestCase

test_net_if_addrs_ips(self)
test_net_if_stats(self)
test_net_io_counters(self)
test_net_connections_ipv6_unsupported(self, supports_ipv6, inet_ntop)
test_net_connections_mocked(self)
class TestSystemDisks

Bases:psutil.tests.unittest.TestCase

test_disk_partitions_and_usage(self)
test_disk_partitions_mocked(self)
test_disk_partitions_procfs(self)
test_disk_io_counters_kernel_2_4_mocked(self)
test_disk_io_counters_kernel_2_6_full_mocked(self)
test_disk_io_counters_kernel_2_6_limited_mocked(self)
test_disk_io_counters_include_partitions(self)
test_disk_io_counters_exclude_partitions(self)
test_disk_io_counters_sysfs(self)
test_disk_io_counters_not_impl(self)
class TestMisc

Bases:psutil.tests.unittest.TestCase

test_boot_time(self)
test_no_procfs_on_import(self)
test_cpu_steal_decrease(self)
test_boot_time_mocked(self)
test_users_mocked(self)
test_procfs_path(self)
test_issue_687(self)
test_pid_exists_no_proc_status(self)
class TestSensorsBattery

Bases:psutil.tests.unittest.TestCase

test_percent(self)
test_power_plugged(self)
test_emulate_power_plugged(self)
test_emulate_power_plugged_2(self)
test_emulate_power_not_plugged(self)
test_emulate_power_not_plugged_2(self)
test_emulate_power_undetermined(self)
test_emulate_no_base_files(self)
test_emulate_energy_full_0(self)
test_emulate_energy_full_not_avail(self)
test_emulate_no_power(self)
class TestSensorsTemperatures

Bases:psutil.tests.unittest.TestCase

test_emulate_eio_error(self)
test_emulate_class_hwmon(self)
test_emulate_class_thermal(self)
class TestSensorsFans

Bases:psutil.tests.unittest.TestCase

test_emulate_data(self)
class TestProcess

Bases:psutil.tests.unittest.TestCase

tearDown
setUp(self)
test_memory_full_info(self)
test_memory_full_info_mocked(self)
test_open_files_mode(self)
test_open_files_file_gone(self)
test_open_files_fd_gone(self)
test_terminal_mocked(self)
test_cmdline_mocked(self)
test_cmdline_spaces_mocked(self)
test_threads_mocked(self)
test_exe_mocked(self)
test_issue_1014(self)
test_rlimit_zombie(self)
test_cwd_zombie(self)
test_stat_file_parsing(self)
test_status_file_parsing(self)
class TestProcessAgainstStatus

Bases:psutil.tests.unittest.TestCase

/proc/pid/stat and /proc/pid/status have many values in common. Whenever possible, psutil uses /proc/pid/stat (it’s faster). For all those cases we check that the value found in /proc/pid/stat (by psutil) matches the one found in /proc/pid/status.

classmethod setUpClass(cls)
read_status_file(self, linestart)
test_name(self)
test_status(self)
test_ppid(self)
test_num_threads(self)
test_uids(self)
test_gids(self)
test_num_ctx_switches(self)
test_cpu_affinity(self)
test_cpu_affinity_eligible_cpus(self)
class TestUtils

Bases:psutil.tests.unittest.TestCase

test_cat(self)