[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.118.164.100: ~ $
U

�=�_D,�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	zddl
Z
Wnek
rldZ
YnXzddlZWnek
r�dZYnXddl
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZd
ZdZe
���pdZe�o*e�Zej� ej�!e"��Z#e	j$j%Z%d$dd�Z&Gdd�d�Z'Gdd�de	j(�Z)Gdd�de	j*�Z+Gdd�de+�Z,d%dd�Z-dd�Z.dd �Z/d!d"�Z0e1d#k�r�e0�dS)&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�FcCsB|dkr|dkrtjntj}tr2t||||d�nt||d�dS)N�red)�bold�file)r)�sys�stderr�stdout�
USE_COLORSr�print)�msgZcolorrr�r�F/opt/alt/python38/lib64/python3.8/site-packages/psutil/tests/runner.py�cprint>s
rc@sXeZdZeZdgZdejkr,e�dddg�dd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dS)�
TestLoaderztest_memleaks.pyZWHEELHOUSE_UPLOADER_USERNAMEztest_osx.pyz
test_linux.pyz
test_posix.pycs�fdd�t��j�D�S)Ncs:g|]2}|�d�r|�d�r|�jkrtj��j|��qS)Ztest_�.py)�
startswith�endswith�
skip_files�os�path�join�testdir)�.0�x��selfrr�
<listcomp>Os



�z,TestLoader._get_testmods.<locals>.<listcomp>)r�listdirr"r%rr%r�
_get_testmodsNs

�zTestLoader._get_testmodsccsN|��D]@}t|�}t|�D]*}t||�}t|t�rt|tj�r|VqqdS)zgIterate over all test files in this directory and return
        all TestCase classes in them.
        N)	r)r�dir�getattr�
isinstance�type�
issubclass�unittest�TestCase)r&r �mod�name�objrrr�_iter_testmod_classesTs


�z TestLoader._iter_testmod_classescCs,t��}|��D]}t|�}|�|�q|S�N)r/�	TestSuiter4�loadTestsFromTestCase�addTest)r&�suiter3�testrrr�all`s
zTestLoader.allc	Cs^t��}tj�t�s|Sttd��}|����}W5QRX|D]}tj	�
|�}|�|�q>|S)NZrt)r/r6rr �isfile�FAILED_TESTS_FNAME�open�read�split�defaultTestLoader�loadTestsFromNamer8)r&r9�f�names�nr:rrr�last_failedgszTestLoader.last_failedcCs.|�d�r"tj�tj�|��d}tj�|�S)Nrr)rrr �splitext�basenamer/rArB)r&r2rrr�	from_namess
zTestLoader.from_nameN)�__name__�
__module__�__qualname__�HEREr"rr�environ�extendr)r4r;rFrIrrrrrGs
rcs<eZdZdd�Zdd�Zdd�Zdd�Z�fd	d
�Z�ZS)�ColouredResultcCstj�||�tdd�dS)NZOK�green)r/�
TestResult�
addSuccessr)r&r:rrrrS{szColouredResult.addSuccesscCs"tj�|||�tdddd�dS)N�ERRORrT�r)r/rR�addErrorr�r&r:�errrrrrVszColouredResult.addErrorcCstj�|||�tdd�dS)NZFAILr)r/rR�
addFailurerrWrrrrY�szColouredResult.addFailurecCs&tj�|||�td|��d�dS)Nzskipped: %sZbrown)r/rR�addSkipr�strip)r&r:�reasonrrrrZ�szColouredResult.addSkipcs$t|d|dkd�}t��||�dS)NrrTrU)rr�printErrorList)r&Zflavour�errors��	__class__rrr]�szColouredResult.printErrorList)	rJrKrLrSrVrYrZr]�
__classcell__rrr_rrPys
rPcsfeZdZdZerenejZ�fdd�Z	�fdd�Z
dd�Zdd	�Z�fd
d�Z
dd
�Zdd�Z�ZS)�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.
    cst�j||�t�|_dSr5)r�__init__�set�
failed_tnames)r&�args�kwargsr_rrrc�szColouredTextRunner.__init__cst���|_|jSr5)r�_makeResult�resultr%r_rrrh�szColouredTextRunner._makeResultc	Cs:|jr6ttd�� }|jD]}|�|d�qW5QRXdS)NZwt�
)rer>r=�write)r&rC�tnamerrr�_write_last_failed�s
z%ColouredTextRunner._write_last_failedcCs6|��s2|j|jD]}|d��}|j�|�qdS)Nr)�
wasSuccessfulr^�failures�idre�add)r&ri�trlrrr�_save_result�szColouredTextRunner._save_resultc	sVzt��|�}Wn2ttfk
rB|jj}|��t�d��YnX|�	|�|SdS)Nr
)
r�run�KeyboardInterrupt�
SystemExit�runnerri�printErrorsr�exitrs�r&r9rir_rr�_run�s
zColouredTextRunner._runcCsJ|r&tdddd�tt�t�d�n tdddd�|��t�d�dS)	N�SUCCESSrQTrUrZFAILEDrr
)rrr=rryrm)r&�successrrr�_exit�szColouredTextRunner._exitcCs|�|�}|�|���dSr5)r{r~rnrzrrrrt�s
zColouredTextRunner.run)rJrKrL�__doc__rrPr/�TextTestResultZresultclassrcrhrmrsr{r~rtrarrr_rrb�s
rbc@s,eZdZedd��Zedd��Zdd�ZdS)�ParallelRunnercs0�fdd�}tj�|tj_t�t�}t�||�S)Ncs�||�}t�|j�|Sr5)�atexit�register�close)�fd�mode�kwds�stream�Zorig_fdopenrr�fdopen�s
z+ParallelRunner._parallelize.<locals>.fdopen)rr��concurrencytestZfork_for_tests�NWORKERSZConcurrentTestSuite)r9r�Zforkerrr�r�_parallelize�s

zParallelRunner._parallelizecCs�t��}t��}|D]n}|��dkr(qn8t|tj�rB|jdj}nt|tj�rT|}ntd|��t|dd�rx|�	|�q|�	|�q||fS)Nrzcan't recognize type %rZ
_serialrunF)
r/r6�countTestCasesr,Z_testsr`r0�	TypeErrorr+r8)r9�serial�parallelr:Z
test_classrrr�_split_suite�szParallelRunner._split_suitecCsX|�|�\}}|�|�}tdtddd�t��}|�|�}t��|}t����}tj	|dd�\}}	|	r~td|	d�t
�t��}|�|�}
t��|}|��s�|��d	kr�|�
�tt|j|j|jf�\}}
}tt|
j|
j|
jf�\}}}tt�d
|j||
|||
j||||f
��td|j|
j||tf�|���oH|
��}|�|�dS)Nz(starting parallel tests using %s workersrQTrUr
)Ztimeoutzalive 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{�psutilZProcessZchildrenZ
wait_procsr
rnr�rx�map�lenror^Zskippedr�textwrap�dedentZtestsRunr~)r&r9Z	ser_suiteZ	par_suiterrZparZpar_elapsedZorphansZgoneZaliveZserZser_elapsedZ	par_failsZpar_errsZ	par_skipsZ	ser_failsZser_errsZ	ser_skips�okrrrrt�sV
�

����

�zParallelRunner.runN)rJrKrL�staticmethodr�r�rtrrrrr��s



r�cCsTdd�}|rJtjr|d�n.tdkr.|d�ntdkr@|d�n
ttd�Sttd�S)NcSst|dd�dS)Nz Running serial tests instead.r)r)rrrr�warnszget_runner.<locals>.warnz$Can't run parallel tests on Windows.z(concurrencytest module is not installed.r
zOnly 1 CPU available.)�	verbosity)r�ZWINDOWSr�r�r��	VERBOSITYrb)r�r�rrr�
get_runners



r�cCs t��|�}t�}|�|�dSr5)rrIr�rt)r2r9rwrrr�
run_from_name,sr�cCstjj��dSr5)r�Z_psplatformZcextZset_testingrrrr�setup2sr�cCs�t�d}tj|dd�}|jddddd�|jd	ddd
d�|��\}}|jsVtt�t�}|r�t	|�dkr~|�
�t�d�S|�
|d�}n|jr�|��}n|��}tr�t�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 parallelr
r)r��optparseZOptionParserZ
add_option�
parse_argsrFrr=rr�Zprint_usagerryrIr;rr	r�r�rt)r��parserZoptsrf�loaderr9rwrrr�main9s:��


r��__main__)FN)F)2rZ
__future__rr�r�rrr�r�r/Zctypes�ImportErrorr�r�Zpsutil._commonrrrZpsutil._compatrZpsutil.testsrrr	r
rr�r=�	cpu_countr�rr �abspath�dirname�__file__rMrAr7rrr�rPZTextTestRunnerrbr�r�r�r�r�rJrrrr�<module>sV


	27U
"


Filemanager

Name Type Size Permission Actions
__init__.cpython-38.opt-1.pyc File 44.89 KB 0644
__init__.cpython-38.pyc File 46.44 KB 0644
__main__.cpython-38.opt-1.pyc File 285 B 0644
__main__.cpython-38.pyc File 285 B 0644
runner.cpython-38.opt-1.pyc File 10.84 KB 0644
runner.cpython-38.pyc File 10.84 KB 0644
test_aix.cpython-38.opt-1.pyc File 3.3 KB 0644
test_aix.cpython-38.pyc File 3.3 KB 0644
test_bsd.cpython-38.opt-1.pyc File 19.53 KB 0644
test_bsd.cpython-38.pyc File 19.53 KB 0644
test_connections.cpython-38.opt-1.pyc File 15.13 KB 0644
test_connections.cpython-38.pyc File 15.43 KB 0644
test_contracts.cpython-38.opt-1.pyc File 24.81 KB 0644
test_contracts.cpython-38.pyc File 25.64 KB 0644
test_linux.cpython-38.opt-1.pyc File 67.56 KB 0644
test_linux.cpython-38.pyc File 68.67 KB 0644
test_memleaks.cpython-38.opt-1.pyc File 22.59 KB 0644
test_memleaks.cpython-38.pyc File 22.59 KB 0644
test_misc.cpython-38.opt-1.pyc File 22.69 KB 0644
test_misc.cpython-38.pyc File 22.92 KB 0644
test_osx.cpython-38.opt-1.pyc File 7.1 KB 0644
test_osx.cpython-38.pyc File 7.1 KB 0644
test_posix.cpython-38.opt-1.pyc File 12.36 KB 0644
test_posix.cpython-38.pyc File 12.46 KB 0644
test_process.cpython-38.opt-1.pyc File 45.69 KB 0644
test_process.cpython-38.pyc File 46.52 KB 0644
test_sunos.cpython-38.opt-1.pyc File 1.5 KB 0644
test_sunos.cpython-38.pyc File 1.5 KB 0644
test_system.cpython-38.opt-1.pyc File 25.65 KB 0644
test_system.cpython-38.pyc File 26.92 KB 0644
test_testutils.cpython-38.opt-1.pyc File 15.6 KB 0644
test_testutils.cpython-38.pyc File 16.27 KB 0644
test_unicode.cpython-38.opt-1.pyc File 10.87 KB 0644
test_unicode.cpython-38.pyc File 10.87 KB 0644
test_windows.cpython-38.opt-1.pyc File 27.81 KB 0644
test_windows.cpython-38.pyc File 28 KB 0644