Viewing File: /opt/hc_python/lib/python3.12/site-packages/psutil/tests/__pycache__/test_sudo.cpython-312.pyc

�

h0i����dZddlZddlZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
ddl	mZd	�Zd
�Z
Gd�de�Zy)
z�Tests which are meant to be run as root.

NOTE: keep this module compatible with unittest: we want to run this
file with the unittest runner, since pytest may not be installed for
the root user.
�N)�FREEBSD)�LINUX)�OPENBSD)�WINDOWS)�
CI_TESTING)�PsutilTestCasec��ttd�r3ttd�r#tjtj�Stj�S)N�
clock_gettime�CLOCK_REALTIME)�hasattr�timer
r���G/opt/hc_python/lib64/python3.12/site-packages/psutil/tests/test_sudo.py�get_systimers9���t�_�%�'�$�8H�*I��!�!�$�"5�"5�6�6��9�9�;�rc
��ttd�r6ttd�r&	tjtj|�ytr�ddl}ddl	}tjj|tjj�}	|j|j|j |j#�dz|j$|j&|j(|j*t-|j.dz��ytjd	��#t$rtjd��wxYw#|j0$r*}|j2dk(rtjd���d}~wwxYw)
N�
clock_settimerz
needs rootr�i�i"zneeds Administrator userzsetting systime not supported)rr
rr�PermissionError�unittest�SkipTestr�
pywintypes�win32api�datetime�
fromtimestamp�timezone�utc�
SetSystemTime�year�month�
isoweekday�day�hour�minute�second�int�microsecond�error�winerror)�secsrr�dt�errs     r�set_systimer-!s*���t�_�%�'�$�8H�*I�	2����t�2�2�D�9�
���
�
�
�
,�
,�T�8�3D�3D�3H�3H�
I��	��"�"��������
�
��!�#��������	�	��	�	��B�N�N�T�)�*�	
���� ?�@�@��/�	2��#�#�L�1�1�	2��$���	��|�|�t�#��'�'�(B�C�C���	�s$�$D�A;E�D>�E:�%E5�5E:c��eZdZdZd�Zd�Zd�Zd�Zeje
d�d��Zejed�eje
d	�ejed
�d����Zejed�d
��Zy)�TestUpdatedSystemTimez$Tests which update the system clock.c�b�d|_t�|_tj�|_y)NF)�time_updatedr�	orig_timer
�	monotonic�time_started��selfs r�setUpzTestUpdatedSystemTime.setUpBs"��!���$���� �N�N�,��rc��|jr:tj�|jz
}t	|j
|z�yy�N)r1r
r3r4r-r2)r6�extra_ts  r�tearDownzTestUpdatedSystemTime.tearDownGs8������n�n�&��):�):�:�G������0�1�rc�B�t|jdz�d|_y)N�T)r-r2r1r5s r�update_systimez$TestUpdatedSystemTime.update_systimeLs���D�N�N�T�)�*� ��rc���tj�}|j�tj�}|j||�t	||z
�}|j|dd��y�Nr=�)�delta)�psutil�	boot_timer>�
assertGreaterr&�assertAlmostEqual�r6�t1�t2�diffs    r�test_boot_timez$TestUpdatedSystemTime.test_boot_timeQs\��
�
�
�
������
�
�
�
�����2�r�"��2��7�|�����t�T���3rzbroken on WINDOWSc���tj�j�}|j�tj�j�}t	||z
�}|j|dd��yr@)rC�Process�create_timer>r&rFrGs    r�test_proc_create_timez+TestUpdatedSystemTime.test_proc_create_timeZs\��
�^�^�
�
)�
)�
+������
�^�^�
�
)�
)�
+���2��7�|�����t�T���3rzskipped on CI for nowzbroken on OPENBSDzbroken on FREEBSDc���tj�}|j�tj�}|j|j	�|j	��|j||�yr9)rCrMr>�assertEqual�
_get_ident)r6�p1�p2s   r�test_proc_identz%TestUpdatedSystemTime.test_proc_identesT���^�^�
������
�^�^�
���������"�-�-�/�:�����R� rz
LINUX onlyc�*�tj�jjd��}|j	�tjd�tj�jjd��}|j||�y)NT)r3g�������?)rCrM�_procrNr>r
�sleeprQ)r6rHrIs   r�test_linux_monotonic_proc_timez4TestUpdatedSystemTime.test_linux_monotonic_proc_timeosj��
�^�^�
�
#�
#�
/�
/�$�
/�
?�������
�
�4��
�^�^�
�
#�
#�
/�
/�$�
/�
?������R� rN)�__name__�
__module__�__qualname__�__doc__r7r;r>rKr�skipIfrrOrrrrUrrYrrrr/r/?s���.�-�
2�
!�
4��X�_�_�W�1�2�4�3�4��X�_�_�Z�!8�9��X�_�_�W�1�2��X�_�_�W�1�2�!�3�3�:�!��X�_�_��Y��-�!�.�!rr/)r]rr
rrCrrrr�psutil.testsrrrr-r/rrr�<module>r`sA������
�����#�'��A�<6!�N�6!r
Back to Directory File Manager