%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3.6/test/libregrtest/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3.6/test/libregrtest/__pycache__/main.cpython-36.pyc

3

/�$h]V�@spddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&yddl'Z'Wne(k
�rdZ'YnXej)��r@ej*d�a+t+dk�r0ej*d�a+ej,j-t+d	�a+ne	j.�a+ej,j/t+�a+Gd
d�d�Z0ddd
�Z1dS)�N)�_parse_args)�	findtests�runtest�get_abs_module�STDTESTS�NOTTESTS�PASSED�FAILED�ENV_CHANGED�SKIPPED�RESOURCE_DENIED�INTERRUPTED�CHILD_ERROR�TEST_DID_NOT_RUN�PROGRESS_MIN_TIME�format_test_result)�setup_tests)�removepy�count�format_duration�	printlist)�supportZabs_builddirZsrcdirZbuildc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd)d%d&�Zd'd(�Zd$S)*�RegrtestalExecute a test suite.

    This also parses command-line options and modifies its behavior
    accordingly.

    tests -- a list of strings containing test names (optional)
    testdir -- the directory in which to look for tests (optional)

    Users other than the Python test suite will certainly want to
    specify testdir; if it's omitted, the directory containing the
    Python test suite is searched for.

    If the tests argument is omitted, the tests listed on the
    command-line will be used.  If that's empty, too, then all *.py
    files beginning with test_ will be used.

    The other default arguments (verbose, quiet, exclude,
    single, randomize, findleaks, use_resources, trace, coverdir,
    print_slow, and random_seed) allow programmers calling main()
    directly to set the values that would normally be set by flags
    on the command line.
    cCs�d|_g|_g|_g|_g|_g|_g|_g|_g|_g|_	d|_
d|_g|_d|_
g|_tj�|_d|_d|_d|_d|_d|_dS)NF��)�ns�tests�selected�good�bad�skipped�resource_denieds�environment_changed�rerun�run_no_tests�first_result�interrupted�
test_times�tracer�
found_garbage�time�	monotonic�
start_time�
test_count�test_count_width�next_single_test�next_single_filename�
testsuite_xml)�self�r3�+/usr/lib/python3.6/test/libregrtest/main.py�__init__Cs*
zRegrtest.__init__cCs2|\}}}|ttfkr&|jj||f�|tkr<|jj|�n�|ttfkrV|jj|�nx|tkrl|j	j|�nb|t
kr�|jj|�nL|tkr�|jj|�|j
j|�n*|tkr�|jj|�n|tkr�td|��|�r.ddljj}xL|D]D}y|jj|j|��Wq�|jk
�r(t|tjd��Yq�Xq�WdS)Nzinvalid test result: %rr)�file)rr
r'�appendrrr	rr
r"rr rr!rr$�
ValueError�xml.etree.ElementTree�etree�ElementTreer1Z
fromstringZ
ParseError�print�sys�
__stderr__)r2�test�result�ok�	test_timeZxml_data�ET�er3r3r4�accumulate_resultks4

zRegrtest.accumulate_resultcCs�|jjrdS||j��|j��}t|j�t|j�}|rP|jjrP|�d|��}d|�d|��}tt	d�r�t	j
�d}d|d�d|��}tj�|j
}tjt|�d	�}|�d|��}t|d
d�dS)N�/�[z] �
getloadavgrz
load avg: z.2f� )ZsecondsT)�flush)r�quietr.r-�lenrr"�pgo�hasattr�osrHr*r+r,�datetimeZ	timedelta�intr<)r2�
test_indexr?�lineZfailsZ
load_avg_1minrBr3r3r4�display_progress�s
zRegrtest.display_progresscCs�ttjdd�f|�}|jr<ttd�r<tdtjd�d|_|jdk	rbt	dkrbtdtjd�d|_|j
r�t	dk	rrntdtjd�d|_
|jr�gt_
|_t|j�|S)NrZdump_traceback_laterzFWarning: The timeout option requires faulthandler.dump_traceback_later)r6z$No GC available, ignore --threshold.z&No GC available, disabling --findleaksF)rr=�argvZtimeoutrN�faulthandlerr<�stderrZ	threshold�gc�	findleaks�xmlpathrZjunit_xml_listr1r�args)r2�kwargsrr3r3r4�
parse_args�s$


zRegrtest.parse_argsc'Cs�||_|jjrdtjjtd�|_y0t|jd��}|j	�j
�}|g|_WdQRXWntk
rbYnX|jjr�g|_t
jd�}ttjjtj|jj���N}xF|D]>}|jdd�d}|j
�}|j|�}|dk	r�|jj|j��q�WWdQRXt|j�tdd�}tj�}|jj�rJx0|jjD]$}	|	|k�r2|j|	�|j|	��qWg|j_|jj�rjt|jjt�t ��}
nt|jj||�}
|jj�s�|j�p�|jj�p�|
|_!n|j|_!|jj�r�|j!dd�|_!y"|
j"|j!d�}|
|d|_#Wnt$k
�r�YnX|jj%�rNy|j!d|j!j"|jj%��=Wn,t&k
�rLt'd|jj%t(j)d�YnX|jj*�r�|jj+dk�rtt,j-d	�|j_+t,j.|jj+�t,j/|j!�dS)
NZ
pynexttest�rz\btest_[a-zA-Z0-9_]+\b�#rrz1Couldn't find starting test (%s), using all tests)r6i���)0rr�singlerO�path�join�TEMPDIRr0�open�read�strip�OSErrorZfromfile�re�compiler�SAVEDCWD�split�searchr7�grouprrr�copyZexcluder[�remove�addZtestdirr�list�setr�indexr/�
IndexError�startr8r<r=rW�	randomize�random_seed�randomZ	randrangeZseedZshuffle)r2r�fpZ	next_testZregexrS�matchZstdtestsZnottests�argZalltests�posr3r3r4�
find_tests�sh











zRegrtest.find_testscCsx|jD]}t|�qWdS)N)rr<)r2�namer3r3r4�
list_testsszRegrtest.list_testscCs\xV|D]N}t|tjj�rqt|tj�r2|j|�qt|tj�rtj|�rt	|j
��qWdS)N)�
isinstance�unittest�loaderZ_FailedTestZ	TestSuite�_list_casesZTestCaserZ
match_testr<�id)r2�suiter?r3r3r4r�s

zRegrtest._list_casescCs�dt_tj|jj�xX|jD]N}t|j|�}ytjj	|�}|j
|�Wqtjk
rh|jj
|�YqXqW|jr�ttjd�ttt|j�d�dtjd�t|jtjd�dS)NF)r6r?zskipped:)r�verboseZset_match_testsrZmatch_testsrrr�ZdefaultTestLoaderZloadTestsFromNamer�ZSkipTestr r7r<r=rWrrLr)r2r?Zabstestr�r3r3r4�
list_casesszRegrtest.list_casescCs�d|j_d|j_d|j_|j�|_t�td�|jdd�|_x�|jD]p}td|dd�yd|j_t	|j|�}Wn"t
k
r�d|_t�PYqHX|dtt
tthkrH|jj|�qHW|jr�ttt|j�d�d�t|j�|j�dS)	NTFz'Re-running failed tests in verbose modez"Re-running test %r in verbose mode)rJrr?z
failed again:)rr�ZfailfastZverbose3�get_tests_resultr%r<rr#r�KeyboardInterruptr&rr
rrrorrLr�display_result)r2r?rAr3r3r4�rerun_failed_tests"s,

zRegrtest.rerun_failed_testscCs0|jjrdSt�td|j��|jr~t�td�t|j�t|j�Bt|j�B}t|j	�|}tt
t|�d�d�t|�|jr�|jj
r�t�|jr�|jr�|jr�t|j�dkr�tddd�tt
t|j�d�d	�|jj�r4|jjd
d�t�td�x0|jdd
�D]\}}td|t|�f��qW|j�rbt�tt
t|j�d�d�t|j�|j�r�t�tdjt
t|j�d���t|j�|j�r�|jj
�r�t�tt
t|j�d�d�t|j�|j�r�t�tdt
t|j�d��t|j�|j�r,t�tt
t|j�d�d�t|j�dS)Nz== Tests result: %s ==z(Test suite interrupted by signal SIGINT.r?zomitted:rZAllrI)�endzOK.T)�reversez10 slowest tests:�
z- %s: %szfailed:z%{} altered the execution environment:zskipped:z%s:zre-run testz
run no tests:)rrMr<r�r&rrrrr rrrLrrKZ
print_slowr'�sortrr"�formatr#r$)r2ZexecutedZomittedr*r?r3r3r4r�@s\




zRegrtest.display_resultc
Cs�|jjr ddl}|jddd�|_tjj�}td�d}�x�t|j	d�D�]|\}}t
j�}|}|rld||f}|j||�|jr�d}t
t��}	|jj|t�|	d	�|	d
}
nLyt|j|�}
Wn.tk
r�d|_|j|tddf�PYnX|j||
�t||
d�}t
j�|}|tk�r,d|t|�f}n|
dtk�r>d}|jj�r�tj�tj�r�tdttj�d
d�td�|jj tj�tjdd�=x4tjj�D]&}||k�r�|j!d��r�t"j#|��q�WqFW|�r�t|�dS)NrFT)�tracerzRun tests sequentiallyrz%s -- %szEresult = runtest(self.ns, test); self.accumulate_result(test, result))�globals�localsr@z%s in %szWarning: test createdrI)r�zuncollectable object(s).ztest.)$rr�ZTracer(r=�modules�keysr<�	enumeraterr*r+rT�dictr�Zrunctxr�rr�r&rEr
rrrrrYrXZcollectZgarbagerLr)�extend�
startswithrZunload)
r2r�Zsave_modulesZ
previous_testrRr?r,�text�cmdrr@rB�moduler3r3r4�run_tests_sequential{sT




zRegrtest.run_tests_sequentialccs:x4x.|D]&}|V|jrdS|jjr|jrdSqWqWdS)N)rr�fail_env_changedr")r2rr?r3r3r4�
_test_forever�s
zRegrtest._test_forevercCsvtdtj�ftjj���tdtjdd�dtj�tdtj��tj	�}|rXtd|�tdt
jd�tj�f�dS)	Nz==T)Zaliasedz	%s-endianz== cwd:z
== CPU count:z== encodings: locale=%s, FS=%sF)
r<�platformZpython_implementationr=�versionrk�	byteorderrO�getcwd�	cpu_count�locale�getpreferredencoding�getfilesystemencoding)r2r�r3r3r4�display_header�s
zRegrtest.display_headercCs�g}|jr|jd�n@|jjr0|jr0|jd�n&t|j|j|j|j|jf�sV|jd�|jrf|jd�|st|jd�dj	|�}|j
r�d|j
|f}|S)N�FAILUREzENV CHANGEDzNO TEST RUNr
�SUCCESSz, z
%s then %s)rr7rr�r"�anyrr r&rbr%)r2r@r3r3r4r��s 




zRegrtest.get_tests_resultcCs|jjs0|jjp,|jjp,|jjp,|jp,|jjr8|j�|jjrj|jj\}}}|dkrjd}t	|t
jdd�|jjr�t	d|jj
�|jjr�|jt|j��|_d|_d|_n.t|j�|_djt|j��|_t|j�d|_|jjr�d	d
lm}||�n|j�dS)N�zhWARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives!T)r6rJzUsing random seedrz/{}rr)�run_tests_multiprocess)r�headerrMrKr`rr[r��
huntrleaksr<r=�stdoutrvrwZforeverr�rqrr-r.�iterr�rLZuse_mp�test.libregrtest.runtest_mpr�r�)r2�warmup�repetitions�_�msgr�r3r3r4�	run_tests�s,
zRegrtest.run_testscCs�|jrB|jr6t|jd��}|j|jd�WdQRXntj|j�|jrf|jj�}|jdd|j	j
d�t�tj
�|j}tdt|��td|j��|j	jr�tjdtj��dS)N�w�
T)Zshow_missingZsummary�coverdirzTotal duration: %szTests result: %szleaks %d)r0r/rd�writerO�unlinkr(ZresultsZ
write_resultsrr�r<r*r+r,rr�Zrunleaks�system�getpid)r2ryr^Zdurationr3r3r4�finalizes
zRegrtest.finalizec
Cs|jjr|jrdSddljj}|jd�}dddd�}x\|jD]R}|j|�xB|D]:}y ||t|j	|d��7<WqTt
k
r�YqTXqTWq@Wx$|j�D]\}}|j|t
|��q�Wtjjtj|jj�}t|d��$}x|j|�D]}	|j|	�q�WWdQRXdS)NrZ
testsuites)r�errorsZfailures�wb)rrZr1r9r:r;ZElementr7rQ�getr8�itemsrr�strrOrarbrrjrdZtostringlistr�)
r2rC�rootZtotalsr��k�vrZ�f�sr3r3r4�save_xml_results$


 zRegrtest.save_xml_resultNcKsrtj�r,ytjt�Wntk
r*YnXdjtj��}tjj	t|�}t
j|dd��|j||�WdQRXdS)Nztest_python_{}T)rK)
�	sysconfig�is_python_buildrO�mkdirrc�FileExistsErrorr�r�rarbrZtemp_cwd�_main)r2rr\Ztest_cwdr3r3r4�main2sz
Regrtest.maincCsZ|j|�|_|jjrP|jj\}}}|dks2|dkrPd}t|tjdd�tjd�|jjdk	rtddlm	}||jj�|jj
r�td�|jjt
_t|j�|j|�|jjr�|j�tjd�|jjr�|j�tjd�|j�|j�|jjr�|jr�|j�|j�|j�|j�rtjd�|j�r0tjd	�|jj�rL|j�rLtjd
�tjd�dS)NrzwInvalid values for the --huntrleaks/-R parameters. The number of warmups and repetitions must be at least 1 each (1:1).T)r6rJ�r)�run_tests_workerzPress any key to continue...�r�)r]rr�r<r=rW�exitZworker_argsr�r��wait�inputrMrZPGOrr}rr�r�r�Zverbose2rr�r�r�r&r�r")r2rr\r�r�r�r�r�r3r3r4r�HsD








zRegrtest._main)N)�__name__�
__module__�__qualname__�__doc__r5rErTr]r}rr�r�r�r�r�r�r�r�r�r�r�r�r�r3r3r3r4r,s(( E
;>	
 
rcKst�jfd|i|��dS)zRun the Python suite.rN)rr�)rr\r3r3r4r�|sr�)N)2rPrVr�rOr�rxrhr=r�Ztempfiler*r�Ztest.libregrtest.cmdlinerZtest.libregrtest.runtestrrrrrrr	r
rrr
rrrrZtest.libregrtest.setuprZtest.libregrtest.utilsrrrrr?rrX�ImportErrorr�Zget_config_varrcrarbZ
gettempdir�abspathrr�r3r3r3r4�<module>sBD




T

Zerion Mini Shell 1.0