HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib/python3.10/site-packages/psutil/tests/__pycache__/test_contracts.cpython-310.pyc
o

=i�/�@spdZddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
ddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZdS)#z�Contracts tests. These tests mainly check API sanity in terms of
returned types and APIs availability.
Some of these are duplicates of tests test_system.py and test_process.py.
�N)�AIX)�FREEBSD)�LINUX)�MACOS)�NETBSD)�OPENBSD)�POSIX)�SUNOS)�WINDOWS)�AARCH64)�GITHUB_ACTIONS)�HAS_CPU_FREQ)�HAS_NET_IO_COUNTERS)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�SKIP_SYSCONS)�PsutilTestCase)�create_sockets)�enum)�
is_namedtuple)�kernel_version)�pytestc@sHeZdZdd�Zdd�Zdd�Zdd�Zejj	e
oed	d
�dd��Zd
S)�TestAvailConstantsAPIscCsttd�tp	tp	tks
J�dS)NZPROCFS_PATH)�hasattr�psutilrr	r��self�r�I/opt/osm/venv/lib/python3.10/site-packages/psutil/tests/test_contracts.py�test_PROCFS_PATH/sz'TestAvailConstantsAPIs.test_PROCFS_PATHcCspttd�tks	J�ttd�tksJ�ttd�tksJ�ttd�tks$J�ttd�tks-J�ttd�tks6J�dS)NZABOVE_NORMAL_PRIORITY_CLASSZBELOW_NORMAL_PRIORITY_CLASSZHIGH_PRIORITY_CLASSZIDLE_PRIORITY_CLASSZNORMAL_PRIORITY_CLASSZREALTIME_PRIORITY_CLASS�rrr
rrrr�test_win_priority2sz(TestAvailConstantsAPIs.test_win_prioritycC�Lttd�tks	J�ttd�tksJ�ttd�tksJ�ttd�tks$J�dS)NZIOPRIO_CLASS_NONEZIOPRIO_CLASS_RTZIOPRIO_CLASS_BEZIOPRIO_CLASS_IDLE�rrrrrrr�test_linux_ioprio_linux:�z.TestAvailConstantsAPIs.test_linux_ioprio_linuxcCr")NZIOPRIO_HIGHZ
IOPRIO_NORMALZ
IOPRIO_LOWZIOPRIO_VERYLOWr rrrr�test_linux_ioprio_windows@r%z0TestAvailConstantsAPIs.test_linux_ioprio_windows�%unsupported on GITHUB_ACTIONS + LINUX��reasoncCs�ttd�tkstsJ�ttd�tkstsJ�ttd�tks!ts!J�ttd�tks,ts,J�ttd�tks7ts7J�ttd�tksBtsBJ�ttd�tksMtsMJ�ttd�tksXtsXJ�ttd	�tksctscJ�ttd
�tksntsnJ�ttd�tksytsyJ�ttd�tks�J�tr�t�d
kr�ttd�tks�J�t�dkr�ttd�tks�J�t�dkr�ttd�tks�J�t�dkr�ttd�tks�J�t�d
kr�ttd�tks�J�ttd�tks�J�ttd�tks�J�ttd�tks�J�dS)NZ
RLIM_INFINITYZ	RLIMIT_ASZRLIMIT_COREZ
RLIMIT_CPUZRLIMIT_DATAZRLIMIT_FSIZEZRLIMIT_MEMLOCKZ
RLIMIT_NOFILEZRLIMIT_NPROCZ
RLIMIT_RSSZRLIMIT_STACKZRLIMIT_LOCKS)���ZRLIMIT_MSGQUEUE)r*r+�ZRLIMIT_NICEZ
RLIMIT_RTPRIO)r*r+�Z
RLIMIT_RTTIMEZRLIMIT_SIGPENDINGZRLIMIT_SWAPZ
RLIMIT_SBSIZEZRLIMIT_NPTS)rrrrrrrrrr�test_rlimitFs4




z"TestAvailConstantsAPIs.test_rlimitN)
�__name__�
__module__�__qualname__rr!r$r&r�mark�skipifrrr/rrrrr.s�rc@sPeZdZdd�Zdd�Zejjeoe	dd�dd��Z
d	d
�Zdd�Zd
d�Z
dS)�TestAvailSystemAPIscC�ttd�tks	J�dS)NZwin_service_iterr rrrr�test_win_service_iterj�z)TestAvailSystemAPIs.test_win_service_itercCr6)NZwin_service_getr rrrr�test_win_service_getmr8z(TestAvailSystemAPIs.test_win_service_get�skipped due to #1892r(cCs&ttd�tp
tp
tp
tp
tksJ�dS)N�cpu_freq)rrrrr
rrrrrr�
test_cpu_freqps�z!TestAvailSystemAPIs.test_cpu_freqcCsttd�tptksJ�dS)N�sensors_temperatures)rrrrrrrr�test_sensors_temperaturesvsz-TestAvailSystemAPIs.test_sensors_temperaturescCr6)N�sensors_fansr#rrrr�test_sensors_fansyr8z%TestAvailSystemAPIs.test_sensors_fanscCs"ttd�tptptptksJ�dS)NZsensors_battery)rrrr
rrrrrr�test_battery|s�z TestAvailSystemAPIs.test_batteryN)r0r1r2r7r9rr3r4rrr<r>r@rArrrrr5is
r5c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	j
eoedd�d
d��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestAvailProcessAPIscCs4ttjd�tptptptptptpt	pt
ksJ�dS)N�environ)rr�Processrrr
rr	rrrrrrr�test_environ�s 
�������z!TestAvailProcessAPIs.test_environcC�ttjd�tks
J�dS�NZuids�rrrDrrrrr�	test_uids��zTestAvailProcessAPIs.test_uidscCrFrGrHrrrr�	test_gids�rJzTestAvailProcessAPIs.test_gidscCrF)N�terminalrHrrrr�
test_terminal�rJz"TestAvailProcessAPIs.test_terminalcC�ttjd�tptksJ�dS)NZionice)rrrDrr
rrrr�test_ionice�sz TestAvailProcessAPIs.test_ionicer'r(cCrN)NZrlimit)rrrDrrrrrrr/�sz TestAvailProcessAPIs.test_rlimitcCs"ttjd�}|tp
tksJ�dS)NZio_counters)rrrDrr	�rZhasitrrr�test_io_counters�sz%TestAvailProcessAPIs.test_io_counterscCrF)NZnum_fdsrHrrrr�test_num_fds�rJz!TestAvailProcessAPIs.test_num_fdscCrF)NZnum_handles)rrrDr
rrrr�test_num_handles�rJz%TestAvailProcessAPIs.test_num_handlescC� ttjd�tp
tp
tksJ�dS)NZcpu_affinity)rrrDrr
rrrrr�test_cpu_affinity��

�z&TestAvailProcessAPIs.test_cpu_affinitycCrT)NZcpu_num)rrrDrrr	rrrr�test_cpu_num�rVz!TestAvailProcessAPIs.test_cpu_numcCs*ttjd�}|tptptptksJ�dS)NZmemory_maps)rrrDrrrrrPrrr�test_memory_maps�sz%TestAvailProcessAPIs.test_memory_mapsN)r0r1r2rErIrKrMrOrr3r4rrr/rQrRrSrUrWrXrrrrrB�s"�
rBc@seZdZdZedd��Zedfdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zej
jeo)edd�ej
jedd�dd���Zdd�Zdd�Zej
jedd�dd��Zdd�Zdd�Zej
jedd�dd ��Zej
jedd�d!d"��Zej
jedd�d#d$��Zd%d&�Zd'd(�Z d)S)*�TestSystemAPITypeszhCheck the return types of system related APIs.
    https://github.com/giampaolo/psutil/issues/1039.
    cCst��|_dS�N)rrD�proc)�clsrrr�
setUpClass�szTestSystemAPITypes.setUpClassTcCs8t|�sJ�|D]}t||�sJ�|r|dksJ�qdS�Nr)r�
isinstance)r�nt�type_Zgezero�nrrr�assert_ntuple_of_nums�s��z(TestSystemAPITypes.assert_ntuple_of_numscCs.|�t���tjdd�D]}|�|�q
dS)NT)Zpercpu)rcrZ	cpu_times)rr`rrr�test_cpu_times�s�z!TestSystemAPITypes.test_cpu_timescCs0ttjdd�t�sJ�ttjdd�t�sJ�dS)N��intervalg�h㈵��>)r_rZcpu_percent�floatrrrr�test_cpu_percent�sz#TestSystemAPITypes.test_cpu_percentcCs(|�tjdd��|�tjdd��dS)Nreg-C��6?)rcrZcpu_times_percentrrrr�test_cpu_times_percent�sz)TestSystemAPITypes.test_cpu_times_percentcC�tt��t�s	J�dSrZ)r_r�	cpu_count�intrrrr�test_cpu_count�r8z!TestSystemAPITypes.test_cpu_countr:r(z
not supportedcCs0t��durt�d�S|jt��ttfd�dS)Nzcpu_freq() returns None�ra)rr;r�skiprcrgrlrrrrr<�s
z TestSystemAPITypes.test_cpu_freqcCs:tjdd���D]\}}t|t�sJ�|j|td�qdS)NT)Zperdiskrn)rZdisk_io_counters�itemsr_�strrcrl)r�k�vrrr�test_disk_io_counters�s�z(TestSystemAPITypes.test_disk_io_counterscCsRt��D]"}t|jt�sJ�t|jt�sJ�t|jt�sJ�t|jt�s&J�qdSrZ)rZdisk_partitionsr_ZdevicerqZ
mountpointZfstype�opts)rZdiskrrr�test_disk_partitions�s�z'TestSystemAPITypes.test_disk_partitionsz
requires rootcCsdt��%t�d�}t|�tt|��ksJ�|D]}t|�sJ�qWd�dS1s+wYdS)N�all)rrZnet_connections�len�setr)r�ret�connrrr�test_net_connections�s
�"�z'TestSystemAPITypes.test_net_connectionscCs�t����D]9\}}t|t�sJ�|D]+}t|jtj�sJ�t|jt�s&J�t|j	tt
d�f�s2J�t|jtt
d�f�s>J�qqdSrZ)rZnet_if_addrsrpr_rq�familyr�IntEnum�address�netmask�type�	broadcast)r�ifname�addrs�addrrrr�test_net_if_addrs�s��z$TestSystemAPITypes.test_net_if_addrscCsjt����D],\}}t|t�sJ�t|jt�sJ�t|jtj	�s"J�t|j
t�s*J�t|jt�s2J�qdSrZ)
rZnet_if_statsrpr_rqZisup�boolZduplexrr~�speedrlZmtu)rr��inforrr�test_net_if_statss�z$TestSystemAPITypes.test_net_if_statscCs$tjdd�D]	}t|t�sJ�qdS)NT)Zpernic)rZnet_io_countersr_rq)rr�rrr�test_net_io_counterss�z'TestSystemAPITypes.test_net_io_counterscCs\t����D]%\}}t|t�sJ�|D]}t|jt�sJ�t|jttt	d�f�s*J�qqdSrZ)
rr?rpr_rq�label�currentrgrlr��r�nameZunits�unitrrrr@s��z$TestSystemAPITypes.test_sensors_fanscCs�t����D]?\}}t|t�sJ�|D]1}t|jt�sJ�t|jttt	d�f�s*J�t|j
ttt	d�f�s7J�t|jttt	d�f�sDJ�qqdSrZ)rr=rpr_rqr�r�rgrlr��high�criticalr�rrrr> s��z,TestSystemAPITypes.test_sensors_temperaturescCrjrZ)r_rZ	boot_timergrrrr�test_boot_time+sz!TestSystemAPITypes.test_boot_timecCs�t��D];}t|jt�sJ�t|jttd�f�sJ�t|jttd�f�s&J�t|jt	td�f�s2J�t|jt	�r?|jdks?J�qdSr^)
rZusersr_r�rqrLr��host�pidrl)r�userrrr�
test_users/s��zTestSystemAPITypes.test_usersN)!r0r1r2�__doc__�classmethodr]rgrcrdrhrirmrr3r4rrr
r<rtrvrr|r�r�rr�rr@rr>r�r�rrrrrY�s4


	



rYc@s&eZdZejjedd�dd��ZdS)�TestProcessWaitTypez	not POSIXr(cCsDt�|��j�}|��|��}|tjksJ�t|t	j
�s J�dSrZ)rrDZ
spawn_subprocr��	terminate�wait�signal�SIGTERMr_rr~)r�p�coderrr�test_negative_signal;s
z(TestProcessWaitType.test_negative_signalN)r0r1r2rr3r4rr�rrrrr�:sr�)r�r�rrrrrrrrr	r
Zpsutil.testsrrr
rrrrrrrrrrrr5rBrYr�rrrr�<module>s<
;>z