403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.133.115.157
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/__pycache__/runner.cpython-37.pyc
B

�=�_D,�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	yddl
Z
Wnek
rldZ
YnXy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)�msg�colorrr�r�F/opt/alt/python37/lib64/python3.7/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_z.py)�
startswith�endswith�
skip_files�os�path�join�testdir)�.0�x)�selfrr�
<listcomp>Osz,TestLoader._get_testmods.<locals>.<listcomp>)r�listdirr")r%r)r%r�
_get_testmodsNs
zTestLoader._get_testmodsccsVxP|��D]D}t|�}x6t|�D]*}t||�}t|t�r t|tj�r |Vq Wq
WdS)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_classescCs0t��}x"|��D]}t|�}|�|�qW|S)N)r.�	TestSuiter3�loadTestsFromTestCase�addTest)r%�suiter2�testrrr�all`s
zTestLoader.allc	Csbt��}tj�t�s|Sttd��}|����}WdQRXx"|D]}tj	�
|�}|�|�q@W|S)N�rt)r.r4rr �isfile�FAILED_TESTS_FNAME�open�read�split�defaultTestLoader�loadTestsFromNamer6)r%r7�f�names�nr8rrr�last_failedgs
zTestLoader.last_failedcCs.|�d�r"tj�tj�|��d}tj�|�S)Nz.pyr)rrr �splitext�basenamer.r@rA)r%r1rrr�	from_namess
zTestLoader.from_nameN)�__name__�
__module__�__qualname__�HEREr"rr�environ�extendr(r3r9rErHrrrrrGs
rcs<eZdZdd�Zdd�Zdd�Zdd�Z�fd	d
�Z�ZS)�ColouredResultcCstj�||�tdd�dS)NZOK�green)r.�
TestResult�
addSuccessr)r%r8rrrrR{szColouredResult.addSuccesscCs"tj�|||�tdddd�dS)N�ERRORrT)r)r.rQ�addErrorr)r%r8�errrrrrTszColouredResult.addErrorcCstj�|||�tdd�dS)NZFAILr)r.rQ�
addFailurer)r%r8rUrrrrV�szColouredResult.addFailurecCs&tj�|||�td|��d�dS)Nzskipped: %s�brown)r.rQ�addSkipr�strip)r%r8�reasonrrrrX�szColouredResult.addSkipcs$t|d|dkd�}t��||�dS)NrrS)r)rr�printErrorList)r%Zflavour�errors)�	__class__rrr[�szColouredResult.printErrorList)	rIrJrKrRrTrVrXr[�
__classcell__rr)r]rrOys
rOcsfeZdZdZerenejZ�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�|_dS)N)r�__init__�set�
failed_tnames)r%�args�kwargs)r]rrr`�szColouredTextRunner.__init__cst���|_|jS)N)r�_makeResult�result)r%)r]rrre�szColouredTextRunner._makeResultc	Cs>|jr:ttd��$}x|jD]}|�|d�qWWdQRXdS)N�wt�
)rbr=r<�write)r%rB�tnamerrr�_write_last_failed�sz%ColouredTextRunner._write_last_failedcCs:|��s6x,|j|jD]}|d��}|j�|�qWdS)Nr)�
wasSuccessfulr\�failures�idrb�add)r%rf�trjrrr�_save_result�szColouredTextRunner._save_resultc	sVyt��|�}Wn2ttfk
rB|jj}|��t�d��YnX|�	|�|SdS)Nr
)
r�run�KeyboardInterrupt�
SystemExit�runnerrf�printErrorsr�exitrq)r%r7rf)r]rr�_run�s
zColouredTextRunner._runcCsJ|r&tdddd�tt�t�d�n tdddd�|��t�d�dS)	N�SUCCESSrPT)rrZFAILEDrr
)rrr<rrwrk)r%�successrrr�_exit�szColouredTextRunner._exitcCs|�|�}|�|���dS)N)rxr{rl)r%r7rfrrrrr�s
zColouredTextRunner.run)rIrJrK�__doc__rrOr.�TextTestResultZresultclassr`rerkrqrxr{rrr^rr)r]rr_�s
r_c@s,eZdZedd��Zedd��Zdd�ZdS)�ParallelRunnercs0�fdd�}tj�|tj_t�t�}t�||�S)Ncs�||�}t�|j�|S)N)�atexit�register�close)�fd�mode�kwds�stream)�orig_fdopenrr�fdopen�s
z+ParallelRunner._parallelize.<locals>.fdopen)rr��concurrencytestZfork_for_tests�NWORKERSZConcurrentTestSuite)r7r�Zforkerr)r�r�_parallelize�s

zParallelRunner._parallelizecCs�t��}t��}xv|D]n}|��dkr*qn8t|tj�rD|jdj}nt|tj�rV|}ntd|��t|dd�rz|�	|�q|�	|�qW||fS)Nrzcan't recognize type %rZ
_serialrunF)
r.r4�countTestCasesr+Z_testsr]r/�	TypeErrorr*r6)r7�serial�parallelr8Z
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 workersrPT)rr
)�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��timerx�psutilZProcess�childrenZ
wait_procsr
rlr�rv�map�lenrmr\Zskippedr�textwrap�dedentZtestsRunr{)r%r7Z	ser_suiteZ	par_suiterp�parZpar_elapsedZorphansZgone�aliveZserZser_elapsedZ	par_failsZpar_errsZ	par_skipsZ	ser_failsZser_errsZ	ser_skips�okrrrrr�s<



zParallelRunner.runN)rIrJrK�staticmethodr�r�rrrrrrr~�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��WINDOWSr�r�r~�	VERBOSITYr_)r�r�rrr�
get_runners



r�cCs t��|�}t�}|�|�dS)N)rrHr�rr)r1r7rurrr�
run_from_name,sr�cCstjj��dS)N)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��optparse�OptionParser�
add_option�
parse_argsrErr<rr�Zprint_usagerrwrHr9rr	r�r�rr)r��parser�optsrc�loaderr7rurrr�main9s2


r��__main__)FN)F)2r|�
__future__rrr�rrr�r�r.�ctypes�ImportErrorr�r�Zpsutil._commonrrrZpsutil._compatrZpsutil.testsrrr	r
rr�r<�	cpu_countr�rr �abspath�dirname�__file__rLr@r5rrr}rOZTextTestRunnerr_r~r�r�r�r�rIrrrr�<module>sV


	27U
"


Youez - 2016 - github.com/yon3zu
LinuXploit