HEX
Server: LiteSpeed
System: Linux atali.colombiahosting.com.co 5.14.0-570.12.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 06:11:55 EDT 2025 x86_64
User: coopserp (1713)
PHP: 8.2.29
Disabled: dl,exec,passthru,proc_open,proc_close,shell_exec,memory_limit,system,popen,curl_multi_exec,show_source,symlink,link,leak,listen,diskfreespace,tmpfile,ignore_user_abord,highlight_file,source,show_source,fpaththru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setid,posix_times,posix_ttyname,posix_uname,proc_get_status,proc_nice,proc_terminate
Upload Files
File: //usr/local/lib64/python3.9/site-packages/psutil/tests/__pycache__/test_contracts.cpython-39.pyc
a

��?h!1�@s�dZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddl
mZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZGdd�de�ZGdd�de�ZGdd �d e�Z Gd!d"�d"e�Z!Gd#d$�d$e�Z"dS)%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)�long)�GITHUB_ACTIONS)�HAS_CPU_FREQ)�HAS_NET_IO_COUNTERS)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�PYPY)�	QEMU_USER)�SKIP_SYSCONS)�PsutilTestCase)�create_sockets)�enum)�
is_namedtuple)�kernel_version)�pytestc@sHeZdZdd�Zdd�Zdd�Zdd�Zejj	e
o4ed	d
�dd��Zd
S)�TestAvailConstantsAPIscCsttd�tptptksJ�dS)NZPROCFS_PATH)�hasattr�psutilrr	r��self�r�G/usr/local/lib64/python3.9/site-packages/psutil/tests/test_contracts.py�test_PROCFS_PATH3sz'TestAvailConstantsAPIs.test_PROCFS_PATHcCsj|j}|ttd�t�|ttd�t�|ttd�t�|ttd�t�|ttd�t�|ttd�t�dS)NZABOVE_NORMAL_PRIORITY_CLASSZBELOW_NORMAL_PRIORITY_CLASSZHIGH_PRIORITY_CLASSZIDLE_PRIORITY_CLASSZNORMAL_PRIORITY_CLASSZREALTIME_PRIORITY_CLASS��assertEqualrrr
�rZaerrr �test_win_priority6sz(TestAvailConstantsAPIs.test_win_prioritycCsJ|j}|ttd�t�|ttd�t�|ttd�t�|ttd�t�dS)NZIOPRIO_CLASS_NONEZIOPRIO_CLASS_RTZIOPRIO_CLASS_BEZIOPRIO_CLASS_IDLE)r#rrrr$rrr �test_linux_ioprio_linux?s
z.TestAvailConstantsAPIs.test_linux_ioprio_linuxcCsJ|j}|ttd�t�|ttd�t�|ttd�t�|ttd�t�dS)NZIOPRIO_HIGHZ
IOPRIO_NORMALZ
IOPRIO_LOWZIOPRIO_VERYLOWr"r$rrr �test_linux_ioprio_windowsFs
z0TestAvailConstantsAPIs.test_linux_ioprio_windows�%unsupported on GITHUB_ACTIONS + LINUX��reasoncCs�|j}|ttd�tpt�|ttd�tp*t�|ttd�tp>t�|ttd�tpRt�|ttd�tpft�|ttd�tpzt�|ttd�tp�t�|ttd�tp�t�|ttd	�tp�t�|ttd
�tp�t�|ttd�tp�t�|ttd�t�t�r�t�d
k�r|ttd�t�t�dk�r0|ttd�t�t�dk�rL|ttd�t�t�dk�rh|ttd�t�t�d
k�r�|ttd�t�|ttd�t�|ttd�t�|ttd�t�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)r#rrrrrrr$rrr �test_rlimitMs6z"TestAvailConstantsAPIs.test_rlimitN)
�__name__�
__module__�__qualname__r!r%r&r'r�mark�skipifrrr0rrrr r2s	�rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestAvailSystemAPIscCsttd�tksJ�dS)NZwin_service_iter�rrr
rrrr �test_win_service_iterrsz)TestAvailSystemAPIs.test_win_service_itercCsttd�tksJ�dS)NZwin_service_getr7rrrr �test_win_service_getusz(TestAvailSystemAPIs.test_win_service_getcCs&ttd�tptptptptks"J�dS)N�cpu_freq)rrrrr
rrrrrr �
test_cpu_freqxs�z!TestAvailSystemAPIs.test_cpu_freqcCsttd�tptksJ�dS)N�sensors_temperatures)rrrrrrrr �test_sensors_temperatures}sz-TestAvailSystemAPIs.test_sensors_temperaturescCsttd�tksJ�dS)N�sensors_fans)rrrrrrr �test_sensors_fans�sz%TestAvailSystemAPIs.test_sensors_fanscCs"ttd�tptptptksJ�dS)NZsensors_battery)rrrr
rrrrrr �test_battery�s�z TestAvailSystemAPIs.test_batteryN)	r1r2r3r8r9r;r=r?r@rrrr r6qsr6c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	j
eo<edd�d
d��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestAvailProcessAPIscCs4ttjd�tp(tp(tp(tp(tp(tp(t	p(t
ks0J�dS)N�environ)rr�Processrrr
rr	rrrrrrr �test_environ�s 
�������z!TestAvailProcessAPIs.test_environcCsttjd�tksJ�dS�NZuids�rrrCrrrrr �	test_uids�szTestAvailProcessAPIs.test_uidscCsttjd�tksJ�dSrErFrrrr �	test_gids�szTestAvailProcessAPIs.test_gidscCsttjd�tksJ�dS)N�terminalrFrrrr �
test_terminal�sz"TestAvailProcessAPIs.test_terminalcCsttjd�tptksJ�dS)NZionice)rrrCrr
rrrr �test_ionice�sz TestAvailProcessAPIs.test_ionicer(r)cCsttjd�tptksJ�dS)NZrlimit)rrrCrrrrrr r0�sz TestAvailProcessAPIs.test_rlimitcCs"ttjd�}|tptksJ�dS)NZio_counters)rrrCrr	�rZhasitrrr �test_io_counters�sz%TestAvailProcessAPIs.test_io_counterscCsttjd�tksJ�dS)NZnum_fdsrFrrrr �test_num_fds�sz!TestAvailProcessAPIs.test_num_fdscCsttjd�tksJ�dS)NZnum_handles)rrrCr
rrrr �test_num_handles�sz%TestAvailProcessAPIs.test_num_handlescCs ttjd�tptptksJ�dS)NZcpu_affinity)rrrCrr
rrrrr �test_cpu_affinity�s

�z&TestAvailProcessAPIs.test_cpu_affinitycCs ttjd�tptptksJ�dS)NZcpu_num)rrrCrrr	rrrr �test_cpu_num�s

�z!TestAvailProcessAPIs.test_cpu_numcCs*ttjd�}|tptptptks&J�dS)NZmemory_maps)rrrCrrrrrLrrr �test_memory_maps�sz%TestAvailProcessAPIs.test_memory_mapsN)r1r2r3rDrGrHrJrKrr4r5rrr0rMrNrOrPrQrRrrrr rA�s �
rAc@s&eZdZdZedd��Zedfdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zej
jeoZe��dkdd�ej
jedd�dd���Zdd�Zdd�Zej
jedd�dd��Zdd�Zej
jedd�dd ��Zej
jedd�d!d"��Zej
jedd�d#d$��Zej
jedd�d%d&��Z d'd(�Z!d)d*�Z"d+S),�TestSystemAPITypesz�Check the return types of system related APIs.
    Mainly we want to test we never return unicode on Python 2, see:
    https://github.com/giampaolo/psutil/issues/1039.
    cCst��|_dS�N)rrC�proc)�clsrrr �
setUpClass�szTestSystemAPITypes.setUpClassTcCs8t|�sJ�|D]"}t||�s"J�|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]}|�|�qdS)NT)Zpercpu)r\rZ	cpu_times)rrYrrr �test_cpu_times�sz!TestSystemAPITypes.test_cpu_timescCs0ttjdd�t�sJ�ttjdd�t�s,J�dS)N��intervalg�h㈵��>)rXrZcpu_percent�floatrrrr �test_cpu_percent�sz#TestSystemAPITypes.test_cpu_percentcCs(|�tjdd��|�tjdd��dS)Nr^g-C��6?)r\rZcpu_times_percentrrrr �test_cpu_times_percent�sz)TestSystemAPITypes.test_cpu_times_percentcCstt��t�sJ�dSrT)rXr�	cpu_count�intrrrr �test_cpu_count�sz!TestSystemAPITypes.test_cpu_count�arm64zskipped due to #1892r)z
not supportedcCs2t��durt�d��|jt��tttfd�dS)Nzcpu_freq() returns None�rZ)rr:r�skipr\r`rdrrrrr r;�s
z TestSystemAPITypes.test_cpu_freqcCs>tjdd���D](\}}t|t�s&J�|j|ttfd�qdS)NT)Zperdiskrg)rZdisk_io_counters�itemsrX�strr\rdr)r�k�vrrr �test_disk_io_counters�sz(TestSystemAPITypes.test_disk_io_counterscCsRt��D]D}t|jt�sJ�t|jt�s,J�t|jt�s<J�t|jt�sJ�qdSrT)rZdisk_partitionsrXZdevicerjZ
mountpointZfstype�opts)rZdiskrrr �test_disk_partitions�s
z'TestSystemAPITypes.test_disk_partitionsz
requires rootcCsbt��Ht�d�}t|�tt|��ks*J�|D]}t|�s.J�q.Wd�n1sT0YdS)N�all)rrZnet_connections�len�setr)r�ret�connrrr �test_net_connectionss

z'TestSystemAPITypes.test_net_connectionscCs�t����D]�\}}t|t�s"J�|D]t}tdurJtsJt|jtj�sZJ�nt|jt	�sZJ�t|j
t�sjJ�t|jttd�f�s�J�t|j
ttd�f�s&J�q&qdSrT)rZnet_if_addrsrirXrjrr�family�IntEnumrd�address�netmask�type�	broadcast)r�ifname�addrs�addrrrr �test_net_if_addrssz$TestSystemAPITypes.test_net_if_addrszQEMU user not supportedcCs�t����D]r\}}t|t�s"J�t|jt�s2J�tdurNt|jtj	�s^J�nt|jt
�s^J�t|jt
�snJ�t|jt
�sJ�qdSrT)
rZnet_if_statsrirXrjZisup�boolrZduplexrwrd�speedZmtu)rr|�inforrr �test_net_if_statssz$TestSystemAPITypes.test_net_if_statscCs$tjdd�D]}t|t�sJ�qdS)NT)Zpernic)rZnet_io_countersrXrj)rr|rrr �test_net_io_counters"sz'TestSystemAPITypes.test_net_io_counterscCs\t����D]J\}}t|t�s"J�|D].}t|jt�s:J�t|jttt	d�f�s&J�q&qdSrT)
rr>rirXrj�label�currentr`rdrz�r�nameZunits�unitrrr r?(s
z$TestSystemAPITypes.test_sensors_fanscCs�t����D]~\}}t|t�s"J�|D]b}t|jt�s:J�t|jttt	d�f�sTJ�t|j
ttt	d�f�snJ�t|jttt	d�f�s&J�q&qdSrT)rr<rirXrjr�r�r`rdrz�high�criticalr�rrr r=1sz,TestSystemAPITypes.test_sensors_temperaturescCstt��t�sJ�dSrT)rXrZ	boot_timer`rrrr �test_boot_time<sz!TestSystemAPITypes.test_boot_timecCsjt��D]\}t|jt�sJ�t|jttd�f�s4J�t|jttd�f�sLJ�t|jt	td�f�sJ�qdSrT)
rZusersrXr�rjrIrz�host�pidrd)r�userrrr �
test_users@s
zTestSystemAPITypes.test_usersN)#r1r2r3�__doc__�classmethodrWr`r\r]rarbrerr4r5r�platform�machiner
r;rmrorrurrr�rr�rr?rr=r�r�rrrr rS�s8
�






rSc@s&eZdZejjedd�dd��ZdS)�TestProcessWaitTypez	not POSIXr)cCs\t�|��j�}|��|��}|tjks0J�tdurJt	|tj
�sXJ�nt	|t�sXJ�dSrT)rrCZspawn_testprocr��	terminate�wait�signal�SIGTERMrrXrwrd)r�p�coderrr �test_negative_signalJsz(TestProcessWaitType.test_negative_signalN)r1r2r3rr4r5rr�rrrr r�Isr�)#r�r�r�rrrrrrrrr	r
Zpsutil._compatrZpsutil.testsrr
rrrrrrrrrrrrrr6rArSr�rrrr �<module>sB?>