ok

Mini Shell

Direktori : /opt/imunify360/venv/lib/python3.11/site-packages/psutil/tests/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/psutil/tests/__pycache__/runner.cpython-311.pyc

�

2�DgD,���dZddlmZddlZddlZddlZddlZddlZddlZddl	Z		ddl
Z
n
#e$rdZ
YnwxYw	ddlZn
#e$rdZYnwxYwddl
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZd
ZdZe
j��pdZeo	e��Zej� ej�!e"����Z#e	j$j%Z%dd�Z&Gd�d��Z'Gd�de	j(��Z)Gd�de	j*��Z+Gd�de+��Z,d d�Z-d�Z.d�Z/d�Z0e1dkre0��dSdS)!aA
Unit test runner, providing new features on top of unittest module:
- colourized output
- parallel run (UNIX only)
- print failures/tracebacks on CTRL+C
- re-run failed tests only (make test-failed)

Invocation examples:
- make test
- make test-failed

Parallel:
- make test-parallel
- make test-process ARGS=--parallel
�)�print_functionN)�hilite)�print_color)�term_supports_colors)�super)�
CI_TESTING)�import_module_by_path)�
print_sysinfo)�
reap_children)�safe_rmpath�z.failed-tests.txt�Fc��|�|dkrtjntj}trt	||||���dSt||���dS)N�red)�bold�file)r)�sys�stderr�stdout�
USE_COLORSr�print)�msg�colorrrs    �u/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/tests/runner.py�cprintr>sZ���|�"�e�^�^�s�z�z�������C��T��5�5�5�5�5�5�
�c��������c�v�eZdZeZdgZdejvre�gd���d�Z	d�Z
d�Zd�Zd�Z
d	S)
�
TestLoaderztest_memleaks.py�WHEELHOUSE_UPLOADER_USERNAME)ztest_osx.pyz
test_linux.pyz
test_posix.pyc�N���fd�tj�j��D��S)Nc���g|]Z}|�d��rC|�d��r.|�jv�5tj��j|����[S)�test_�.py)�
startswith�endswith�
skip_files�os�path�join�testdir)�.0�x�selfs  �r�
<listcomp>z,TestLoader._get_testmods.<locals>.<listcomp>Osn���*�*�*���<�<��(�(�*�-.�Z�Z��->�->�*����(�(�����T�\�1�-�-�)�(�(r)r'�listdirr*)r-s`r�
_get_testmodszTestLoader._get_testmodsNs:���*�*�*�*���D�L�1�1�*�*�*�	*rc#�K�|���D]f}t|��}t|��D]E}t||��}t	|t
��rt
|tj��r|V��F�gdS)zgIterate over all test files in this directory and return
        all TestCase classes in them.
        N)	r0r	�dir�getattr�
isinstance�type�
issubclass�unittest�TestCase)r-r(�mod�name�objs     r�_iter_testmod_classesz TestLoader._iter_testmod_classesTs������&�&�(�(�	�	�D�'��-�-�C��C���
�
���c�4�(�(���c�4�(�(��"�3��(9�:�:���I�I�I��	
�	�	rc��tj��}|���D]&}t|��}|�|���'|S�N)r7�	TestSuiter<�loadTestsFromTestCase�addTest)r-�suiter;�tests    r�allzTestLoader.all`sR���"�$�$���-�-�/�/�	 �	 �C�(��-�-�D��M�M�$������rc��tj��}tj�t
��s|St
t
d��5}|������}ddd��n#1swxYwY|D]6}tj	�
|��}|�|���7|S)N�rt)r7r?r'r(�isfile�FAILED_TESTS_FNAME�open�read�split�defaultTestLoader�loadTestsFromNamerA)r-rB�f�names�nrCs      r�last_failedzTestLoader.last_failedgs����"�$�$���w�~�~�0�1�1�	��L�
�$�d�
+�
+�	%�q��F�F�H�H�N�N�$�$�E�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%��	 �	 �A��-�?�?��B�B�D��M�M�$������s�'B�B�	Bc���|�d��rBtj�tj�|����d}t
j�|��S)Nr#r)r%r'r(�splitext�basenamer7rLrM)r-r:s  r�	from_namezTestLoader.from_namessW���=�=����	?��7�#�#�B�G�$4�$4�T�$:�$:�;�;�A�>�D��)�;�;�D�A�A�ArN)�__name__�
__module__�__qualname__�HEREr*r&r'�environ�extendr0r<rDrQrU�rrrrGs��������G�$�%�J�%���3�3����K�K�K�L�L�L�*�*�*�
�
�
����
�
�
�B�B�B�B�Brrc�6��eZdZd�Zd�Zd�Zd�Z�fd�Z�xZS)�ColouredResultc�f�tj�||��tdd��dS)N�OK�green)r7�
TestResult�
addSuccessr)r-rCs  rrczColouredResult.addSuccess{s1����&�&�t�T�2�2�2��t�W�����rc�l�tj�|||��tddd���dS)N�ERRORrT�r)r7rb�addErrorr�r-rC�errs   rrgzColouredResult.addErrors8����$�$�T�4��5�5�5��w��D�)�)�)�)�)�)rc�h�tj�|||��tdd��dS)N�FAILr)r7rb�
addFailurerrhs   rrlzColouredResult.addFailure�s3����&�&�t�T�3�7�7�7��v�u�����rc��tj�|||��td|���zd��dS)Nzskipped: %s�brown)r7rb�addSkipr�strip)r-rC�reasons   rrozColouredResult.addSkip�s@����#�#�D�$��7�7�7��}�v�|�|�~�~�-�w�7�7�7�7�7rc�x��t|d|dk���}t���||��dS)Nrrerf)rr�printErrorList)r-�flavour�errors�	__class__s   �rrszColouredResult.printErrorList�s<�����%�g��.@�A�A�A��
�����w��/�/�/�/�/r)	rVrWrXrcrgrlrors�
__classcell__�rvs@rr^r^yst����������*�*�*����8�8�8�0�0�0�0�0�0�0�0�0rr^c�d��eZdZdZerenejZ�fd�Z	�fd�Z
d�Zd�Z�fd�Z
d�Zd�Z�xZS)	�ColouredTextRunnerz�
    A coloured text runner which also prints failed tests on KeyboardInterrupt
    and save failed tests in a file so that they can be re-run.
    c�`��t��j|i|��t��|_dSr>)r�__init__�set�
failed_tnames)r-�args�kwargsrvs   �rr|zColouredTextRunner.__init__�s1��������$�)�&�)�)�)� �U�U����rc�\��t�����|_|jSr>)r�_makeResult�result)r-rvs �rr�zColouredTextRunner._makeResult�s$����g�g�)�)�+�+����{�rc��|jrSttd��5}|jD]}|�|dz���	ddd��dS#1swxYwYdSdS)N�wt�
)r~rIrH�write)r-rN�tnames   r�_write_last_failedz%ColouredTextRunner._write_last_failed�s�����	*��(�$�/�/�
*�1�!�/�*�*�E��G�G�E�D�L�)�)�)�)�*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*�
*�
*�	*�	*s�#A�A�Ac��|���sF|j|jzD]8}|d���}|j�|���7dSdS)Nr)�
wasSuccessfulru�failures�idr~�add)r-r��tr�s    r�_save_resultzColouredTextRunner._save_result�sm���#�#�%�%�	.��]�V�_�4�
.�
.���!����	�	���"�&�&�u�-�-�-�-�	.�	.�
.�
.rc���	t���|��}|�|��|S#ttf$r5|jj}|���tj	d���wxYw)Nr)
r�runr��KeyboardInterrupt�
SystemExit�runnerr��printErrorsr�exit)r-rBr�rvs   �r�_runzColouredTextRunner._run�s����	��W�W�[�[��'�'�F�
���f�%�%�%��M��
"�:�.�	�	�	��[�'�F���� � � ��(�1�+�+��	���s
�!;�ABc��|r<tddd���tt��tjd��dStddd���|���tjd��dS)	N�SUCCESSraTrfr�FAILEDrr)rrrHrr�r�)r-�successs  r�_exitzColouredTextRunner._exit�sw���	��9�g�D�1�1�1�1��*�+�+�+��H�Q�K�K�K�K�K��8�U��.�.�.�.��#�#�%�%�%��H�Q�K�K�K�K�Krc�~�|�|��}|�|�����dSr>)r�r�r�)r-rBr�s   rr�zColouredTextRunner.run�s7�����5�!�!���
�
�6�'�'�)�)�*�*�*�*�*r)rVrWrX�__doc__rr^r7�TextTestResult�resultclassr|r�r�r�r�r�r�rwrxs@rrzrz�s����������%/�K�.�.�H�4K�K�#�#�#�#�#������*�*�*�.�.�.�	�	�	�	�	����+�+�+�+�+�+�+rrzc�@�eZdZed���Zed���Zd�ZdS)�ParallelRunnerc����fd�}tj�|tj_tjt��}tj||��S)Nc�R���||��}tj|j��|Sr>)�atexit�register�close)�fd�mode�kwds�stream�orig_fdopens    �r�fdopenz+ParallelRunner._parallelize.<locals>.fdopen�s+��� �[��T�*�*�F��O�F�L�)�)�)��Mr)r'r��concurrencytest�fork_for_tests�NWORKERS�ConcurrentTestSuite)rBr��forkerr�s   @r�_parallelizezParallelRunner._parallelize�sS���	�	�	�	�	��i��$*���!� �/��9�9���2�5�&�A�A�Arc���tj��}tj��}|D]�}|���dkr�t|tj��r|jdj}n/t|tj��r|}ntd|z���t|dd��r|�	|����|�	|����||fS)Nrzcan't recognize type %r�
_serialrunF)
r7r?�countTestCasesr4�_testsrvr8�	TypeErrorr3rA)rB�serial�parallelrC�
test_classs     r�_split_suitezParallelRunner._split_suite�s����#�%�%���%�'�'���
	'�
	'�D��"�"�$�$��)�)���D�(�"4�5�5�
B�!�[��^�5�
�
��D�(�"3�4�4�
B�!�
�
�� 9�D� @�A�A�A��z�<��7�7�
'����t�$�$�$�$�� � ��&�&�&�&���!�!rc��|�|��\}}|�|��}tdtzdd���t	j��}|�|��}t	j��|z
}t
j�����}t
j	|d���\}}	|	r!td|	zd��t��t	j��}|�|��}
t	j��|z
}|���s,|���d	kr|�
��tt|j|j|jf��\}}
}tt|
j|
j|
jf��\}}}t't)jd
|j||
|||
j||||f
z����t'd|j|
jz||ztfz��|���o|
���}|�|��dS)Nz(starting parallel tests using %s workersraTrfr)�timeoutzalive processes %srra=
            +----------+----------+----------+----------+----------+----------+
            |          |    total | failures |   errors |  skipped |     time |
            +----------+----------+----------+----------+----------+----------+
            | parallel |      %3s |      %3s |      %3s |      %3s |    %.2fs |
            +----------+----------+----------+----------+----------+----------+
            | serial   |      %3s |      %3s |      %3s |      %3s |    %.2fs |
            +----------+----------+----------+----------+----------+----------+
            z&Ran %s tests in %.3fs using %s workers)r�r�rr��timer��psutil�Process�children�
wait_procsrr�r�r��map�lenr�ru�skippedr�textwrap�dedent�testsRunr�)r-rB�	ser_suite�	par_suiter��par�par_elapsed�orphans�gone�alive�ser�ser_elapsed�	par_fails�par_errs�	par_skips�	ser_fails�ser_errs�	ser_skips�oks                   rr�zParallelRunner.run�sd��#�0�0��7�7��	�9��%�%�i�0�0�	�	�9�H�D��T�	#�	#�	#�	#��I�K�K���i�i�	�"�"���i�k�k�A�o���.�"�"�+�+�-�-���'���;�;�;���e��	��'�%�/��7�7�7��O�O�O�
�I�K�K���i�i�	�"�"���i�k�k�A�o��� � �"�"�	�y�'?�'?�'A�'A�A�'E�'E��O�O����),�S�3�<�36�:�36�;�3@�*A�*A�&�	�8�Y�*-�S�3�<�36�:�36�;�3@�*A�*A�&�	�8�Y�	�h�o���<��H�i���<��H�i��N�	N�	O�	O�		P�		P�		P�	�6��L�3�<�'��{�)B�H�:N�N�	O�	O�	O�
�
�
�
 �
 �
8�S�%6�%6�%8�%8���
�
�2�����rN)rVrWrX�staticmethodr�r�r�r\rrr�r��sZ�������B�B��\�B��"�"��\�"�&.�.�.�.�.rr�c���d�}|rWtjr|d��n?t�|d��n,tdkr|d��nt	t
���St
t
���S)Nc�,�t|dzd��dS)Nz Running serial tests instead.r)r)rs r�warnzget_runner.<locals>.warns���s�5�5�u�=�=�=�=�=rz$Can't run parallel tests on Windows.z(concurrencytest module is not installed.rzOnly 1 CPU available.)�	verbosity)r��WINDOWSr�r�r��	VERBOSITYrz)r�r�s  r�
get_runnerr�s���>�>�>��7��>�	7��D�7�8�8�8�8�
�
$��D�;�<�<�<�<�
��]�]��D�(�)�)�)�)�!�I�6�6�6�6��	�2�2�2�2rc��t���|��}t��}|�|��dSr>)rrUr�r�)r:rBr�s   r�
run_from_namer�,s:���L�L�"�"�4�(�(�E�
�\�\�F�
�J�J�u�����rc�L�tjj���dSr>)r��_psplatform�cext�set_testingr\rr�setupr�2s"�����'�'�)�)�)�)�)rc���t��d}tj|d���}|�dddd���|�d	ddd
���|���\}}|jst
t��t��}|rWt|��dkr(|�
��tjd��S|�
|d��}n0|jr|���}n|���}trt!��t#|j��}|�|��dS)
Nz*python3 -m psutil.tests [opts] [test-name]zrun unit tests)�usage�descriptionz
--last-failed�
store_trueFzonly run last failed tests)�action�default�helpz
--parallelzrun tests in parallelrr)r��optparse�OptionParser�
add_option�
parse_argsrQrrHrr��print_usagerr�rUrDrr
r�r�r�)r��parser�optsr�loaderrBr�s       r�mainr�9se��	�G�G�G�8�E�
�
"��<L�
M�
M�
M�F�
���o�)�5�7��9�9�9����l�)�5�2��4�4�4��"�"�$�$�J�D�$���(��&�'�'�'��\�\�F��	��t�9�9�q�=�=���� � � ��8�A�;�;���$�$�T�!�W�-�-�E�E�	
�	���"�"�$�$����
�
����������
��
�
&�
&�F�
�J�J�u�����r�__main__)FN)F)2r��
__future__rr�r�r'rr�r�r7�ctypes�ImportErrorr�r��psutil._commonrrr�psutil._compatr�psutil.testsrr	r
rrr�rH�	cpu_countr�rr(�abspath�dirname�__file__rYrLr@rrr�r^�TextTestRunnerrzr�r�r�r�r�rVr\rr�<module>rs���� &�%�%�%�%�%�
�
�
�
�����	�	�	�	�
�
�
�
���������������M�M�M�M������
�F�F�F�����������������O�O�O������
�
�
�!�!�!�!�!�!�&�&�&�&�&�&�/�/�/�/�/�/� � � � � � �#�#�#�#�#�#�.�.�.�.�.�.�&�&�&�&�&�&�&�&�&�&�&�&�$�$�$�$�$�$�
�	�(���6����"����^�
6� 4� 4� 6� 6�
�	�w���r�w���x�0�0�1�1�� �2�H������/B�/B�/B�/B�/B�/B�/B�/B�d0�0�0�0�0�X�,�0�0�0�.4+�4+�4+�4+�4+��0�4+�4+�4+�nR�R�R�R�R�'�R�R�R�j3�3�3�3� ���*�*�*����D�z����D�F�F�F�F�F��s�+�5�5�>�A�A

Zerion Mini Shell 1.0