Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/regrtest.cpython-35.opt-2.pyc



���]��"@s�dZdZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZyddlZWnek
r`dZYnXyddlZddlZ Wnek
r�dZ YnXxfej!j"�D]UZ#e$e#d�r�dd�e#j%D�e#_%e$e#d	�r�ej&j'e#j(�e#_(q�Wej
d
kr�yddl)Z)Wnek
r4YnNXe)j*e)j+�\Z,Z-e.e-e/e,dd��Z0e)j1e)j+e0e-f�d
Z2dZ3d
Z4dZ5dZ6dZ7dZ8ddl9m:Z:dddddddddf	Z;e;dfZ<ej=�rej&j>ej?d�d�Z@nejA�Z@ej&j'e@�Z@Gdd �d ejB�ZCd!d"�ZDd#d$�ZEd%d&�ZFd'd(�ZGd)d*�ZHd+d,�ZId-d.�ZJdd/d0�ZKd1d2d3d4d5d6d7d8d9d:g
ZLeM�ZNdeLeNd;d<�ZOGd=d>�d>eP�ZQd?d@�ZRdAddAdAdddBdAdCdD�ZSdeS_TGdEdF�dF�ZUdAdGdAdHdI�ZVdJdK�ZWdLdM�ZXdNdO�ZYdPdQ�ZZdRdS�Z[ddTdU�Z\dVdW�Z]dXdY�Z^dZddd[d\�Z_d]d^�Z`d_d`�Zadadb�Zbdcdd�Zceddekr�ej&j'ej&jeej&jfejgd���Zheiej&�ZjxOejdkr�ejd
8Zjej&j'ej&jeej&ej��ehkr�ej&ej=qfWej&j'e(�Z(ec�dS)fz�python -m test [options] [test_name1 [test_name2 ...]]
python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
a`Run Python regression tests.

If no arguments or options are provided, finds all files matching
the pattern "test_*" in the Lib/test subdirectory and runs
them in alphabetical order (but see -M and -u, below, for exceptions).

For more rigorous testing, it is useful to use the following
command line:

python -E -Wd -m test [options] [test_name1 ...]
a�Additional option details:

-r randomizes test execution order. You can use --randseed=int to provide an
int seed value for the randomizer; this is useful for reproducing troublesome
test orders.

-s On the first invocation of regrtest using -s, the first test file found
or the first test file given on the command line is run, and the name of
the next test is recorded in a file named pynexttest.  If run from the
Python build directory, pynexttest is located in the 'build' subdirectory,
otherwise it is located in tempfile.gettempdir().  On subsequent runs,
the test in pynexttest is run, and the next test is written to pynexttest.
When the last test has been run, pynexttest is deleted.  In this way it
is possible to single step through the test files.  This is useful when
doing memory analysis on the Python interpreter, which process tends to
consume too many resources to run the full regression test non-stop.

-S is used to continue running tests after an aborted run.  It will
maintain the order a standard run (ie, this assumes -r is not used).
This is useful after the tests have prematurely stopped for some external
reason and you want to start running from where you left off rather
than starting from the beginning.

-f reads the names of tests from the file given as f's argument, one
or more test names per line.  Whitespace is ignored.  Blank lines and
lines beginning with '#' are ignored.  This is especially useful for
whittling down failures involving interactions among tests.

-L causes the leaks(1) command to be run just before exit if it exists.
leaks(1) is available on Mac OS X and presumably on some other
FreeBSD-derived systems.

-R runs each test several times and examines sys.gettotalrefcount() to
see if the test appears to be leaking references.  The argument should
be of the form stab:run:fname where 'stab' is the number of times the
test is run to let gettotalrefcount settle down, 'run' is the number
of times further it is run and 'fname' is the name of the file the
reports are written to.  These parameters all have defaults (5, 4 and
"reflog.txt" respectively), and the minimal invocation is '-R :'.

-M runs tests that require an exorbitant amount of memory. These tests
typically try to ascertain containers keep working when containing more than
2 billion objects, which only works on 64-bit systems. There are also some
tests that try to exhaust the address space of the process, which only makes
sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit,
which is a string in the form of '2.5Gb', determines howmuch memory the
tests will limit themselves to (but they may go slightly over.) The number
shouldn't be more memory than the machine has (including swap memory). You
should also keep in mind that swap memory is generally much, much slower
than RAM, and setting memlimit to all available RAM or higher will heavily
tax the machine. On the other hand, it is no use running these tests with a
limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect
to use more than memlimit memory will be skipped. The big-memory tests
generally run very, very long.

-u is used to specify which special resource intensive tests to run,
such as those requiring large file support or network connectivity.
The argument is a comma-separated list of words indicating the
resources to test.  Currently only the following are defined:

    all -       Enable all special resources.

    none -      Disable all special resources (this is the default).

    audio -     Tests that use the audio device.  (There are known
                cases of broken audio drivers that can crash Python or
                even the Linux kernel.)

    curses -    Tests that use curses and will modify the terminal's
                state and output modes.

    largefile - It is okay to run some test that may create huge
                files.  These tests can take a long time and may
                consume >2GB of disk space temporarily.

    network -   It is okay to run tests that use external network
                resource, e.g. testing SSL support for sockets.

    decimal -   Test the decimal module against a large suite that
                verifies compliance with standards.

    cpu -       Used for certain CPU-heavy tests.

    subprocess  Run all tests for the subprocess module.

    urlfetch -  It is okay to download files required on testing.

    gui -       Run tests that require a running GUI.

To enable all resources except one, use '-uall,-<resource>'.  For
example, to run all the tests except for the gui tests, give the
option '-uall,-gui'.

--matchfile filters tests using a text file, one pattern per line.
Pattern examples:

- test method: test_stat_attributes
- test class: FileTests
- test identifier: test_os.FileTests.test_stat_attributes
�N)�
isabstract�__path__cCs"g|]}tjj|��qS�)�os�path�abspath)�.0rrr�-/opt/alt/python35/lib64/python3.5/regrtest.py�
<listcomp>�s	r
�__file__�darwinii�����)�supportZaudioZcursesZ	largefileZnetwork�decimalZcpu�
subprocessZurlfetchZguiZextralargefile�srcdirZbuildcs"eZdZ�fdd�Z�S)�
_ArgParsercst�j|d�dS)Nz%
Pass -h or --help for complete help.)�super�error)�self�message)�	__class__rr	r�sz_ArgParser.error)�__name__�
__module__�__qualname__rrr)rr	r�src
Cs�tdddtdtdtdddtj�}d	}|jd
�}|jddd
ddd�|jddddtdd�|jdd
ddd�|jddd�|jdddddd|�|jd�}|jdd d
d!dd"�|jd#d$d
ddd%�|jd&d'd
ddd(�|jd)d*d
ddd+�|jd,d-d
dd.d/dd0�|jd1d
ddd2�|jd3�}|jd4d5d
ddd6|�|jd7dd8d.d9dt	dd:�|jd;d<dd=dd>|�|jd?d@d
dddA�|jdBdCd
dddD|�|jdEdFddGd.dHd
dIddJ�|jdKddLd.dMddN�|jdOdPd
dddQ�|jdRdSddTd
dIdt
ddU|�|jdVdWddXddY|�|jdZdd[dtdd\�|jd]�}|jd^d_d
ddd`�|jdadbd
dddc|�|jdddeddfdtddg|�|jdhdiddjd.dkdt	ddl�|jdmdnd
dd.doddp�|jdqdrdd[dtdds�|jdtdud
dvdwdd.dxddy�|jdzd{dd|dt	dd}�|jd~dd
ddd��|jd�d�d
ddd��|jd�d
ddd��|jd�d
ddd��|jd�d�d.d�d
ddd��|jd�d
ddd��|S)�N�progzregrtest.py�usage�description�epilog�add_helpF�formatter_classz-  See the section at bottom for more details.zGeneral optionsz-hz--help�action�helpzshow this help message and exitz	--timeout�metavarZTIMEOUT�typezxdump the traceback and exit if a test takes more than TIMEOUT seconds; disabled if TIMEOUT is negative or equals to zeroz--wait�
store_truez:wait for user input, e.g., allow a debugger to be attachedz--slaveargsZARGSz-Sz--startZSTARTz'the name of the test at which to start.Z	Verbosityz-vz	--verbose�countz/run tests in verbose mode with output to stdoutz-wz
--verbose2z#re-run failed tests in verbose modez-Wz
--verbose3zdisplay test output on failurez-qz--quietz'no output unless one or more tests failz-oz	--slowest�dest�
print_slowzprint the slowest 10 testsz--headerz"print header with interpreter infozSelecting testsz-rz--randomizezrandomize test execution order.z
--randseedZSEED�random_seedz5pass a random seed to reproduce a previous random runz-fz
--fromfile�FILEz'read names of tests to run from a file.z-xz	--excludez arguments are tests to *exclude*z-sz--singlez#single step through a set of tests.z-mz--matchZPAT�match_tests�appendz2match test cases and methods with glob pattern PATz--matchfileZFILENAME�match_filenamezJsimilar to --match but get patterns from a text file, one pattern per linez-Gz
--failfastz1fail as soon as a test fails (only with -v or -W)z-uz--usez
RES1,RES2,...z6specify which special resource intensive tests to run.z-Mz
--memlimitZLIMITz&run very large memory-consuming tests.z	--testdirZDIRzWexecute test files in the specified directory (instead of the Python stdlib test suite)zSpecial runsz-lz--findleaksz0if GC is available detect tests that leak memoryz-Lz
--runleaksz*run the leaks(1) command just before exit.z-Rz--huntrleaksZ	RUNCOUNTSz:search for reference leaks (needs debug build, very slow).z-jz--multiprocessZ	PROCESSES�use_mpzrun PROCESSES processes at oncez-Tz
--coverage�tracez4turn on code coverage tracing using the trace modulez-Dz
--coverdirz&directory where coverage files are putz-Nz--nocoverdir�store_const�const�coverdirz$put coverage files alongside modulesz-tz--thresholdZ	THRESHOLDz call gc.set_threshold(THRESHOLD)z-nz--nowindowsz'suppress error message boxes on Windowsz-Fz	--foreverz9run the specified tests in a loop, until an error happensz--list-testszAonly write the name of tests that will be run, don't execute themz--list-caseszGonly write the name of test cases that will be run , don't execute themz-Pz--pgo�pgoz+enable Profile Guided Optimization trainingz--fail-env-changedz>if a test file alters the environment, mark the test as failed)
r�USAGE�DESCRIPTION�EPILOG�argparse�RawDescriptionHelpFormatter�add_argument_group�add_argument�float�int�resources_list�relative_filename�
huntrleaks)�parserZmore_details�grouprrr	�_create_parser�s�rFcCstjjtj|�S)N)rr�joinr�SAVEDCWD)�stringrrr	rBfsrBcCs�|jd�}t|�d
kr0tjd��|drJt|d�nd}|drjt|d�nd}t|�dkr�|dr�|dnd	}|||fS)N�:rrz&needs 2 or 3 colon-separated argumentsrrr
rz
reflog.txt)rr)�split�lenr;�ArgumentTypeErrorr@)rI�args�nwarmup�ntracked�fnamerrr	rCks	  ,rCcCs�dd�|jd�D�}xh|D]`}|dks#|dkrDq#|ddkrd|dd�}|tkr#tjd	|��q#W|S)
NcSsg|]}|j��qSr)�lower)r�xrrr	r
vs	z"resources_list.<locals>.<listcomp>�,�all�noner�-r
zinvalid resource: )rK�RESOURCE_NAMESr;rM)rI�u�rrrr	rAus
rAc
1Ksrtjddddddddddddd	dd
dddddd
ddddddddddddddddddddddddddd�}xI|j�D];\}}t||�s�td|��t|||�q�W|jdkrg|_t�}|jd|d|�d|_	x>|j	D]3}|j
d �r2|jd!|�tj
d�q2W|jr�|jr�|jd"�|jdk	r�|jr�|jd#�|jdk	r�|jr�|jd$�|jdk	r�|jr�|jd%�|jr |jp|jr |jd&�|jr2d|_|jdk	r~ttd'�rk|jdkr~d|_ntd(�d|_|jdk	r�|jdkr�d)tj�p�d|_|jdkr�d|_|jr�x�|jD]�}x�|D]�}|d*krt|jdd�<q�|d+kr4|jdd�=q�d}	|dd kr`d,}	|dd�}|	r�||jkr�|jj|�q�||jkr�|jj |�q�Wq�W|j!dk	r�d,|_"|j#r�|jr�d|_td-d.tj$�|j%rn|j&dkrg|_&tj'j(t)j*|j%�}
t+|
��.}x$|D]}|j&j |j,��qGWWdQRX|S)/N�testdir�verboser�quietF�exclude�single�	randomize�fromfile�	findleaks�
use_resourcesr3r6Zcoverage�runleaksrC�verbose2r,r-r2�verbose3�forever�header�failfastr/r1r7z3%r is an invalid keyword argument for this functionrN�	namespacer
rWzunrecognized arguments: %sz-s and -f don't go together!z-T and -j don't go together!z-l and -j don't go together!z-M and -j don't go together!z#-G/--failfast needs either -v or -W�dump_traceback_laterzFWarning: The timeout option requires faulthandler.dump_traceback_laterrrUrVTznWARNING: Disable --verbose3 because it's incompatible with --huntrleaks: see http://bugs.python.org/issue27103�file)-r;�	Namespace�items�hasattr�	TypeError�setattrrcrF�parse_known_argsrN�
startswithr�sys�exitr_rar2r3rb�memlimitrir\rfr]�timeout�faulthandler�printr�	cpu_countZuse�
ALL_RESOURCES�remover0r-r`rC�stderrr1r/rrGrrH�open�strip)
rN�kwargs�ns�k�vrD�arg�arZr|�filename�fp�linerrr	�_parse_args�s�	
		




		
			
			
		
!r�cCs�ddlm}m}tjgtj�ddddg}|jrR|dg}t|�}||f}t	j
|�}||d|gd	|d
|ddd
tjdkdtj
�}|j�\}}	|j�}
|
||	fS)Nr)�Popen�PIPEz-Xrxz-mz
test.regrtestz--pgoz--slaveargs�stdoutr}�universal_newlinesT�	close_fds�nt�cwd)rr�r�rt�
executablerZargs_from_interpreter_flagsr7�vars�json�dumpsr�namerH�communicate�wait)�testnamer�r�r�Zbase_cmd�ns_dict�	slaveargs�popenr�r}�retcoderrr	�run_test_in_subprocess�s 	
r�cCsz|jr+tjjdtjj|j��|jr;t�|jdk	rZt	j
|j�|jdk	r�ddl}|j
|j�|jr�td�yddl}Wntk
r�Yn�X|j|j|jB|jB|jB�y|jWntk
rYnuXxq|j|j|jgD]W}|jrb|jdkrb|j||j�|j||j�q|j|d�qWdS)NrzSThe --nowindows (-n) option is deprecated. Use -vv to display assertions in stderr.r) r[rtr�insertrrrC�warm_cachesrvrZset_memlimitZ	threshold�gcZ
set_thresholdZ	nowindowsry�msvcrt�ImportErrorZSetErrorModeZSEM_FAILCRITICALERRORSZSEM_NOALIGNMENTFAULTEXCEPTZSEM_NOGPFAULTERRORBOXZSEM_NOOPENFILEERRORBOXZCrtSetReportMode�AttributeErrorZCRT_WARNZ	CRT_ERRORZ
CRT_ASSERTr\ZCRTDBG_MODE_FILEZCrtSetReportFileZCRTDBG_FILE_STDERR)r�r�r��mrrr	�setup_tests�s6	"		


r�c+[stj��tjdd�g}ttd�rA|jtj�ttd�r`|jtj�x!|D]}tj	|dd�qgWt
�tjt
j�tt
jdd�|���jdk	r�tj�j�\}}tj|��t���jrdtj_y[t�|�j�j�jd�jd	�jd
�j d�j!d�j"d
�j#�}Wn^t$k
r�t%df}YnAt&k
r�}z!t'j(�t)t*|�f}WYdd}~XnXt
jj+�t,�t,tj-|��t
j.d�t���j/rt0d�g�g�g�
g�	g�d}�j1r�yddl2}	Wn%t3k
r}t,d�d�_1YnXg}
�jr�dtj_�j4rt5j6j7t8d�}y8t9|d��"}|j:�j;�}
|
g}WdQRXWnt<k
rYnX�j=r�g}t9t5j6j7tj>�j=���w}t?j@d�}x^|D]V}|jAdd�d}|j;�}|jB|�}|dk	rM|j|jC��qMWWdQRXtD�jE�tD|�tFdd�}tGjH�}�jIr-x7�jED],}||kr|jJ|�|jK|�q�Wg�_E�jLrTtM�jLtN�tO��}ntM�jL||�}|p{�jEp{|}�j4r�|dd�}y||jP|d�d}WntQk
r�d}YnX�jRry|d|jP�jR��=Wn#tSk
rt,d�jR�YnX�jTrt�jUdkrGtVjWd��_UtVjX�jU�t,d�jU�tVjY|��jZr�ddlZ}ddl[}|j\dddd�}g��jt_�j#t_#t
j]j^�}����	�
�fdd���j_r,x|D]}t,|�qWt
j.d��j`rOt`�|�t
j.d��jar�tN|����fdd�}|�}d�
d�n1tb|�}d jctd|���
td�
�d��js��jes��j"p��jp��j4p�|p��jEr�t,d!tfjg�t
jhjA��t,d"tfjfd#d�d$t
ji�t,d"d%t
jjjkt
jld[krhd(nd)�t,d"t5jm��t,d*t
jn�����
�fd+d,�}�jor�	ydd-lpmq�Wn)t3k
r�t,d.�t
j.d&�YnXdd/lrms}t?j@d0��|��tt|������fd1d2����fd3d4�tu�jo�D�}x|D]} | jR�qtWd}!d}"y�x�|!�jokrd	�jv�\�}#}$}�dkr�|!d7}!q���|�||"��|#r	t,|#�|$r'	�j"r'	t,|$d5t
jw�t
jj+�t
jwj+�|dt%krW	t$�|"d7}"q�WWn!t$k
r�	d}d�_xYnXxV|D]} | j7�q�	Wn;x8ty|d�D]'\}"�||"�����fd6d7�}%�jZr
|jzd8d9t{�d:t|��n'y|%�Wnt$k
r:
d}PYnX�j1r�
|	j}�|	j~r�
t,d;td|	j~�d<d=�t,d>�|
j|	j~�|	j~dd�=x?t
j]j^�D].}&|&|kr�
|&j�d?�r�
tj�|&�q�
Wq�	W|rT�j"rTt,�t,d@�tO|�tO��tO��tO�
�}'t,t�td|'�dA�dB�t�|'��r��jr��j"r��r��
r�|r�td��dkr�t,dCd<d=�t,t�td��dA�dD��j�r�j�dEd�t,dF�x2�ddG�D] \}(�t,dH�|(f�q�W�rO�j"rOt,t�td��dA�dI�t����r��j"r�t,dJjct�td��dA���t����
r��jr��j"r�t,t�td�
�dA�dK�t��
��j�r�
�r�
t,dL�x��dd�D]���j"s
t,dM��t
jj+�y=d�_t��d�j�jd	�jd�j"�})Wnt$k
rx
t,�PYq�X|)dt�t�t�t�hkr��jJ��q�W�r�
t,t�td��dA�dN�t����j4r|rt9|dO��}|j�|dP�WdQRXn
t5j�|��jZrO|j��}*|*j�dQddRddS�j���j�rot5j�dTt5j����r~dU}n-|r�dV}n�j�r��r�dW}ndX}t,dY|��r�t
j.d&�|r�t
j.dZ��j�r��r�t
j.d�t
j.d�dS)\NZall_threadsT�SIGALRM�SIGUSR1�chainr
F�output_on_failurerwrir/r7rc�rzPress any key to continue...z%No GC available, disabling findleaks.Z
pynexttestrZz\btest_[a-zA-Z0-9_]+\b�#z1Couldn't find starting test (%s), using all testsi���zUsing random seedr3r*cs�|\}}|ttfkr1�j||f�|tkrM�j|�n�|ttfkro�j|�n}|tkr��j|�na|tkr��j|�nE|tkr��j|��j|�n|tkr�td|��dS)Nzinvalid test result: %r)	�CHILD_ERROR�INTERRUPTEDr0�PASSED�FAILED�ENV_CHANGED�SKIPPED�RESOURCE_DENIED�
ValueError)�test�result�ok�	test_time)�bad�environment_changed�good�resource_denieds�skipped�
test_timesrr	�accumulate_result�s 
zmain.<locals>.accumulate_resultc3s>x7x0|D](}|V�rdS�jr
�r
dSq
WqWdS)N)�fail_env_changed)�testsr�)r�r�r�rr	�test_forever�s
zmain.<locals>.test_foreverrz/{}z==z==  Zaliasedz	%s-endianzhash algorithm:r� �64bit�32bitzTesting with flags:cs��jr
dSdj|���}�rJ�jrJdj|t���}dj||�}ttd�r�tj�d}dj||�}tj��}t	j
dt|��}dj||�}t|d	d
�dS)Nz
{0:{1}}{2}z{0}/{1}z	[{0}] {1}�
getloadavgrzload avg: {0:.2f} {1}Zsecondsz{0} {1}�flushT)
r]�formatr7rLrorr��time�	monotonic�datetimeZ	timedeltar@ry)�
test_indexr�r�Z
load_avg_1minr�)r�r��
start_time�
test_count�test_count_widthrr	�display_progresss	zmain.<locals>.display_progress)�Threadz+Multiprocess option requires thread support)�Queuez\[\d+ refs, \d+ blocks\]$csAyxyt��}Wn#tk
r;�jd�dSYnXt|��\}}}�jd|�}|j�jd�\}}}|dkr�td|f}�j||j�|j�|f�q|s��jd�dSt	j
|�}�j||j�|j�|f�qWWn"tk
r<�jd��YnXdS)Nr��
rzExit code %s)NNNN)NNNN)NNNN)�next�
StopIteration�putr��subr�
rpartitionr��rstripr��loads�
BaseException)r�r�r�r}�_r�)�debug_output_patr��output�pendingrr	�work!s,

	%
-

zmain.<locals>.workcsg|]}�d���qS)�targetr)r�i)r�r�rr	r
;s	zmain.<locals>.<listcomp>rlcs_t���j�j�jd�jd�jd�jd�jd�j�}��|�dS)Nr�rwrir/r7)	�runtestr\r]rCrfrwrir/r7)r�)r�r�r�rr	�runtest_accumulateZs		z main.<locals>.runtest_accumulatezruntest_accumulate()�globals�localszWarning: test created�end� zuncollectable object(s).ztest.z(Test suite interrupted by signal SIGINT.r�zomitted:ZAllzOK.�reversez10 slowest tests:�
z- %s: %.1fszfailed:z%{} altered the execution environment:zskipped:z'Re-running failed tests in verbose modez"Re-running test %r in verbose modez
failed again:�wr�Zshow_missingZsummaryr6zleaks %d�FAILUREr�zENV CHANGED�SUCCESSzTests result: %s�l)�r�r�rx�enablero�signalr0r�r��register�replace_stdoutrZrecord_original_stdoutrtr�r��argvr�r�r��types�SimpleNamespacer�rC�unittestZ
BaseTestSuite�_cleanupr�r\r]rfrwrir/r7rc�KeyboardInterruptr�r��	traceback�	print_excr��strr�ryr�rur��inputrbr�r�r_rrrG�TEMPDIRr~�readr�OSErrorrarH�re�compilerK�searchrE�removepyrN�STDTESTS�NOTTESTS�copyr^r|�addr[�	findtests�list�set�index�
IndexError�startr�r`r-�random�	randrange�seed�shuffler3�tempfileZTrace�modules�keysZ
list_tests�
list_casesrg�iterr�rLrh�platformZpython_implementation�version�	byteorder�	hash_info�	algorithm�maxsize�getcwd�flagsr2�	threadingr��queuer��MultiprocessTests�range�getr}�interrupted�	enumerateZrunctxr�r��collectZgarbage�extendrs�unloadr*�	printlistr,�sortrer�r�r�r��write�unlink�resultsZ
write_resultsr6rd�system�getpidr�)+r�r�Zsignals�signumr�r�r��er#r�Z
found_garbager�r�Z	next_testZregexr��match�stdtests�nottestsr�Zalltests�selectedZnext_single_testr3rZtracerZsave_modulesr�r�r�r��workersZworker�finishedr�r�r}r��moduleZomittedr�r�rZr)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	�main"s


			

%


	
	

		
	$


	
			
	
	
	!	

	

	!		+	

	%









	
	
	

*
'	

	


	
	

	
					


r8Ztest_grammarZtest_opcodesZ	test_dictZtest_builtinZtest_exceptionsZ
test_typesZ
test_unittestZtest_doctestZ
test_doctest2Ztest_supportc	Cs�t|�}tj|�}g}t|�|B}xa|D]Y}tjj|�\}}|dd�dkr8|dkr8||kr8|j|�q8W|t|�S)NrZtest_�.pyr�)r9r�)�findtestdirr�listdirr	r�splitextr0�sorted)	r[r2r3�namesr�Zothersr��mod�extrrr	r�s
.rc@s4eZdZdd�Zdd�Zdd�ZdS)r cCs%d|_tj�|_||_dS)NF)r#r�Lock�lockr�)rr�rrr	�__init__�s	zMultiprocessTests.__init__cCs|S)Nr)rrrr	�__iter__�szMultiprocessTests.__iter__c	Cs7|j�'|jrtd��t|j�SWdQRXdS)Nztests interrupted)rBr#r�r�r�)rrrr	�__next__�s
	zMultiprocessTests.__next__N)rrrrCrDrErrrr	r �sr cskddl}tj�t�j�dd�jdddddd	�t_�fd
d�}|j|�dS)Nrr��encoding�errors�backslashreplace�closefdF�newliner�cstjj��t_dS)N)rtr��closer)r�rr	�restore_stdout
s
z&replace_stdout.<locals>.restore_stdout)�atexitrtr�r~�filenorFr�)rMrLr)r�r	r��s		r�Fr7c
Cs�|dk	r|t_|	dk	}|r:tj|	dd�zC|t_|rUdt_|rJdt_tjdkr�t	j
�}|t_n tj}|jd�|j�t
j}
t
j}zt|t
_|t
_t|||||ddd|
�}|dtkr0|
r0|j�}|j|�|j�Wd|
t
_|t
_Xn.|t_t|||||d|d|
�}|SWd|r�tj�t||�XdS)NruTr�display_failureFr7)rrcrxrkr/rir\r��stringio�io�StringIO�seek�truncatertr�r}�
runtest_innerr��getvaluer*r�Zcancel_dump_traceback_later�cleanup_test_droppings)r�r�r\r]rCrcr�rir/rwr7Zuse_timeout�streamZorig_stdoutZorig_stderrr�r�rrr	r�sN					

					
	
		
r�c@s�eZdZdZdddddd�Zd�Zdd�Zdd �Zd!d"�Zd#d$�Z	d%d&�Z
d'd(�Zd)d*�Zd+d,�Z
d-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�ZdEdF�ZdGdH�ZdIdJ�ZdKdL�ZdMdN�ZdOdP�ZdQdR�Z dSdT�Z!dUdV�Z"dWdX�Z#dYdZ�Z$d[d\�Z%d]d^�Z&d_d`�Z'dadb�Z(dcdd�Z)dedf�Z*dgdh�Z+didj�Z,dkdl�Z-dmdn�Z.dodp�Z/dqdr�e0e1�D�Z2dsdt�Z3dudv�Z4dwdx�Z5dydz�Z6d{d|�Z7d}d~�Z8dd��Z9d�S)��saved_test_environmentFrr7cCs(||_||_||_||_dS)N)r�r\r]r7)rr�r\r]r7rrr	rCts			zsaved_test_environment.__init__�sys.argvr��	sys.stdin�
sys.stdout�
sys.stderr�
os.environ�sys.path�sys.path_hooks�
__import__�asyncore.socket_map�logging._handlers�logging._handlerList�sys.gettrace�sys.warnoptions�!multiprocessing.process._dangling�threading._dangling�sysconfig._CONFIG_VARS�sysconfig._INSTALL_SCHEMES�files�locale�warnings.showwarning�shutil_archive_formats�shutil_unpack_formatscCs&ttj�tjtjdd�fS)N)�idrtr�)rrrr	�get_sys_argv�sz#saved_test_environment.get_sys_argvcCs(|dt_|dtjdd�<dS)Nr
r)rtr�)rZ
saved_argvrrr	�restore_sys_argv�s
z'saved_test_environment.restore_sys_argvcCs
tj�S)N)rr)rrrr	�get_cwd�szsaved_test_environment.get_cwdcCstj|�dS)N)r�chdir)rZ	saved_cwdrrr	�restore_cwd�sz"saved_test_environment.restore_cwdcCstjS)N)rtr�)rrrr	�get_sys_stdout�sz%saved_test_environment.get_sys_stdoutcCs
|t_dS)N)rtr�)rZsaved_stdoutrrr	�restore_sys_stdout�sz)saved_test_environment.restore_sys_stdoutcCstjS)N)rtr})rrrr	�get_sys_stderr�sz%saved_test_environment.get_sys_stderrcCs
|t_dS)N)rtr})rZsaved_stderrrrr	�restore_sys_stderr�sz)saved_test_environment.restore_sys_stderrcCstjS)N)rt�stdin)rrrr	�
get_sys_stdin�sz$saved_test_environment.get_sys_stdincCs
|t_dS)N)rtrz)rZsaved_stdinrrr	�restore_sys_stdin�sz(saved_test_environment.restore_sys_stdincCs"ttj�tjttj�fS)N)rpr�environ�dict)rrrr	�get_os_environ�sz%saved_test_environment.get_os_environcCs2|dt_tjj�tjj|d�dS)Nr
r)rr}�clear�update)rZ
saved_environrrr	�restore_os_environ�s

z)saved_test_environment.restore_os_environcCs&ttj�tjtjdd�fS)N)rprtr)rrrr	�get_sys_path�sz#saved_test_environment.get_sys_pathcCs(|dt_|dtjdd�<dS)Nr
r)rtr)rZ
saved_pathrrr	�restore_sys_path�s
z'saved_test_environment.restore_sys_pathcCs&ttj�tjtjdd�fS)N)rprt�
path_hooks)rrrr	�get_sys_path_hooks�sz)saved_test_environment.get_sys_path_hookscCs(|dt_|dtjdd�<dS)Nr
r)rtr�)rZsaved_hooksrrr	�restore_sys_path_hooks�s
z-saved_test_environment.restore_sys_path_hookscCs
tj�S)N)rt�gettrace)rrrr	�get_sys_gettrace�sz'saved_test_environment.get_sys_gettracecCstj|�dS)N)rt�settrace)rZ	trace_fxnrrr	�restore_sys_gettrace�sz+saved_test_environment.restore_sys_gettracecCstjS)N)�builtinsra)rrrr	�get___import__�sz%saved_test_environment.get___import__cCs
|t_dS)N)r�ra)r�import_rrr	�restore___import__�sz)saved_test_environment.restore___import__cCs+tjjd�}|r'|jj�p*iS)N�asyncore)rtrr"�
socket_mapr)rr�rrr	�get_asyncore_socket_map�sz.saved_test_environment.get_asyncore_socket_mapcCsBtjjd�}|dk	r>|jdd�|jj|�dS)Nr�Z
ignore_allT)rtrr"Z	close_allr�r�)rZ	saved_mapr�rrr	�restore_asyncore_socket_map�sz2saved_test_environment.restore_asyncore_socket_mapcCstjtjj�fS)N)�shutil�_ARCHIVE_FORMATSr)rrrr	�get_shutil_archive_formats�sz1saved_test_environment.get_shutil_archive_formatscCs2|dt_tjj�tjj|d�dS)Nrr
)r�r�r�r�)r�savedrrr	�restore_shutil_archive_formats�s

z5saved_test_environment.restore_shutil_archive_formatscCstjtjj�fS)N)r��_UNPACK_FORMATSr)rrrr	�get_shutil_unpack_formats�sz0saved_test_environment.get_shutil_unpack_formatscCs2|dt_tjj�tjj|d�dS)Nrr
)r�r�r�r�)rr�rrr	�restore_shutil_unpack_formats�s

z4saved_test_environment.restore_shutil_unpack_formatscCs"ttj�tjtjj�fS)N)rp�logging�	_handlersr)rrrr	�get_logging__handlers�sz,saved_test_environment.get_logging__handlerscCsdS)Nr)rZsaved_handlersrrr	�restore_logging__handlers�sz0saved_test_environment.restore_logging__handlerscCs&ttj�tjtjdd�fS)N)rpr��_handlerList)rrrr	�get_logging__handlerList�sz/saved_test_environment.get_logging__handlerListcCsdS)Nr)rZsaved_handlerListrrr	�restore_logging__handlerList�sz3saved_test_environment.restore_logging__handlerListcCs&ttj�tjtjdd�fS)N)rprt�warnoptions)rrrr	�get_sys_warnoptions�sz*saved_test_environment.get_sys_warnoptionscCs(|dt_|dtjdd�<dS)Nr
r)rtr�)rZ
saved_optionsrrr	�restore_sys_warnoptions�s
z.saved_test_environment.restore_sys_warnoptionscCsts
dStjj�S)N)r�	_danglingr)rrrr	�get_threading__dangling�sz.saved_test_environment.get_threading__danglingcCs+ts
dStjj�tjj|�dS)N)rr�r�r�)rr�rrr	�restore_threading__dangling�s
z2saved_test_environment.restore_threading__danglingcCs'ts
dStjj�tjjj�S)N)�multiprocessing�processr�r�r)rrrr	�%get_multiprocessing_process__danglings
z<saved_test_environment.get_multiprocessing_process__danglingcCs1ts
dStjjj�tjjj|�dS)N)r�r�r�r�r�)rr�rrr	�)restore_multiprocessing_process__danglingsz@saved_test_environment.restore_multiprocessing_process__danglingcCs/tjd�ttj�tjttj�fS)N�prefix)�	sysconfig�get_config_varrp�_CONFIG_VARSr~)rrrr	�get_sysconfig__CONFIG_VARSs
z1saved_test_environment.get_sysconfig__CONFIG_VARScCs2|dt_tjj�tjj|d�dS)Nr
r)r�r�r�r�)rr�rrr	�restore_sysconfig__CONFIG_VARSs

z5saved_test_environment.restore_sysconfig__CONFIG_VARScCs"ttj�tjtjj�fS)N)rpr��_INSTALL_SCHEMESr)rrrr	�get_sysconfig__INSTALL_SCHEMESsz5saved_test_environment.get_sysconfig__INSTALL_SCHEMEScCs2|dt_tjj�tjj|d�dS)Nr
r)r�r�r�r�)rr�rrr	�"restore_sysconfig__INSTALL_SCHEMESs

z9saved_test_environment.restore_sysconfig__INSTALL_SCHEMEScCstdd�tj�D��S)Ncss1|]'}|tjj|�r$dndVqdS)�/r�N)rr�isdir)r�fnrrr	�	<genexpr>%sz3saved_test_environment.get_files.<locals>.<genexpr>)r=rr;)rrrr	�	get_files$sz saved_test_environment.get_filescCsjtj}||krf|d|krftjj|�rGtj|�ntjj|�rftj|�dS)Nr�)r�TESTFNrr�isfiler+r��rmtree)rZsaved_valuer�rrr	�
restore_files's	z$saved_test_environment.restore_filescCs.g|]$}|jd�rtt|��qS)�LC_)rs�getattrrl)r�lcrrr	r
/s	z!saved_test_environment.<listcomp>c
Cs_g}xR|jD]G}y#|j|tj|d�f�Wqttfk
rVwYqXqW|S)N)�_lcr0rl�	setlocalerpr�)rZpairingsr�rrr	�
get_locale1s#z!saved_test_environment.get_localecCs+x$|D]\}}tj||�qWdS)N)rlr�)rr�r�Zsettingrrr	�restore_locale9sz%saved_test_environment.restore_localecCstjS)N)�warnings�showwarning)rrrr	�get_warnings_showwarning=sz/saved_test_environment.get_warnings_showwarningcCs
|t_dS)N)r�r�)r�fxnrrr	�restore_warnings_showwarning?sz3saved_test_environment.restore_warnings_showwarningccs^xW|jD]L}|jdd�}d|}d|}|t||�t||�fVq
WdS)N�.r�Zget_Zrestore_)�	resources�replacer�)rr�Z
method_suffix�get_nameZrestore_namerrr	�
resource_infoBs


z$saved_test_environment.resource_infocCs&tdd�|j�D��|_|S)Ncss'|]\}}}||�fVqdS)Nr)rr�r"�restorerrr	r�Jsz3saved_test_environment.__enter__.<locals>.<genexpr>)r~r��saved_values)rrrr	�	__enter__Isz saved_test_environment.__enter__c
Cs�|j}|`tj�x�|j�D]�\}}}|�}|j|�}	||	kr&d|_||	�|jr&|jr&tdj	||j
�dtj�tdj	|	|�dtj�q&WdS)NTz Warning -- {} was modified by {}rlz  Before: {}
  After:  {} F)
r�rZ
gc_collectr��pop�changedr]r7ryr�r�rtr})
r�exc_type�exc_val�exc_tbr�r�r"r��currentZoriginalrrr	�__exit__Ns"	
		
	
	zsaved_test_environment.__exit__N)rZr�r[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnro):rrrr�rCr�rqrrrsrurvrwrxryr{r|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��dirrlr�r�r�r�r�r�r�r�rrrr	rYdszrYTcs�tj|�d}d}y�t||�}	t�t|||d|���}
tj�}tj|	��t�dd�}|dkr��fdd�}|�|r�t	�|||�}tj�|}WdQRXWn�tj
k
r1}
z:|r|rt|d|
�tj
j�t|fSWYdd}
~
Xnltjk
r�}
z:|rq|rqt|d|
�tj
j�t|fSWYdd}
~
Xntk
r��Yn�tjk
r#}
z`|s�|r�td|d	|
d
tj�ntd|dd
tj�tjj�t|fSWYdd}
~
Xnztj�}
|sTtd|d|
d
tj�tjj�t|fSYn.X|r�t|fS|
jr�t|fSt|fSdS)
NgFr7Z	test_maincshtj�}|j��}x$|jD]}t|dtj�q%W|jrWtd��tj	|�dS)Nrlzerrors while loading tests)
r�Z
TestLoaderZloadTestsFromModulerGryrtr}�	ExceptionrZrun_unittest)�loaderr�r)�
the_modulerr	�test_runnerss	z"runtest_inner.<locals>.test_runnerz
skipped --r�z	failed --rl�failedz
crashed --)rr'�get_abs_module�clear_cachesrYr��	importlib�
import_moduler��dash_RZResourceDeniedryrtr�r�r�r��SkipTestr�r�Z
TestFailedr}r�r��
format_excr�r�r�)r�r�r\r]rCrOr7r�Zrefleak�abstestZenvironmentr�r��msgr)r�r	rUcs\






	
rUc	Csaddl}ddl}ddl}|j�x,tjdfD]}tjj|�sYq>tjj	|�r~d|j
}}n5tjj|�r�dtj}}nt
d|��|r�td|||f�y>ttd�rtj||j|jB|jB�||�Wq>tk
rX}z(td||||fdtj�WYdd}~Xq>Xq>WdS)	NrZdb_homeZ	directoryrlz8os.path says %r exists but is neither directory nor filez%r left behind %s %r�chmodz3%r left behind %s %r and it couldn't be removed: %s)r��statr�r%rr�rr�existsr�r�r�r+�SystemErrorryror��S_IRWXU�S_IRWXG�S_IRWXOr�rtr})	r�r\r�r�r�r��kindZnukerr�rrr	rW�s.
	

!rWcsddl}ddl�ttd�s3td��tjdd�}|jj�}tj	j�}yddl
}Wntk
r�d}	YnX|jj�}	i}
xg�fdd��j
jD�D]F}t|�s�q�x.|j�|gD]}|jj�|
|<q�Wq�W|\}
}}tjjtj|�}|
|}dg|}dg|}td|ddtj�td	|d
dd|�dtj�tjj�x�t|�D]}}|�t||||	|
�\}}tjjd�tjj�||
kr%||||<||||<||}}q�Wtdtj�d
d�}d}x�|d|f|d|fgD]�\}}}||
d�}||�rwd|||t|�f}t|dtj�tjj�t|d��!}t|d|�|j�WdQRXd}qwW|S)Nr�gettotalrefcountz9Tracking reference leaks requires a debug build of Pythoncs"g|]}t�j|��qSr)r��abc)rr�)�collectionsrr	r
�s	zdash_R.<locals>.<listcomp>Z	beginningZrepetitionsrlZ
1234567890r�r
r�cSstdd�|D��S)Ncss|]}|dkVqdS)r
Nr)rZdeltarrr	r�sz2dash_R.<locals>.check_rc_deltas.<locals>.<genexpr>)rU)�deltasrrr	�check_rc_deltas�s
zdash_R.<locals>.check_rc_deltasFZ
referencesz
memory blocksz%s leaked %s %s, sum=%sr�T)�copyreg�collections.abcrortr�r��filters�dispatch_tabler�path_importer_cache�	zipimportr��_zip_directory_cacher��__all__r�__subclasses__�
_abc_registryrrrGrrHryr}r�r!�dash_R_cleanupr*�sumr~)r�r�Z
indirect_testrCr��fs�ps�picr��zdc�abcsr��objrOrPrQZrepcountZ	rc_deltasZalloc_deltasr�Zalloc_afterZrc_afterZ	rc_beforeZalloc_beforer�r�r�Z	item_nameZcheckerr�Zrefrepr)r�r	r��sh
&


)



r�c
s�ddl}ddl}ddl�ddlm}|tjdd�<|jj�|jj	|�t
jj�t
jj	|�yddl}Wnt
k
r�YnX|jj�|jj	|�t
j��fdd��jjD�}	tt|	�}	dt
jkr9t
jd}
t|	�|
j|
j|
jg}	xd|	D]\}xS|j�|gD]>}|j||��j�|_|jj�|jj�qZWq@Wt�t
j }
t
j!}|j"�|
�|�fS)Nr)�WeakSetcs"g|]}t�j|��qSr)r�r�)rr�)r�rr	r
6s	z"dash_R_cleanup.<locals>.<listcomp>�typing)#r�r�r��weakrefrr�r�r�r�r�rtr�r�r�r��_clear_type_cacher�r��filterrrr�ChainMap�CounterZDefaultDictr�r"rr��
_abc_cache�_abc_negative_cacher��getallocatedblocksr�r%)rrrrrr�r�rr�Zabs_classes�tr�rZfunc1Zfunc2r)r�r	rs<





"

		
rc[Cs�ddl}x,tjj�D]}t|d�r|`qWx<tjtjtjtj	fD]}|dk	rZ|j
�qZWytjd}Wntk
r�YnX|jj
�tj�ytjd}Wntk
r�YnX|jj
�ytjd}Wntk
rYnX|j�ytjd}Wntk
r?YnX|j�ytjd}Wntk
roYnX|j�ytjd}Wntk
r�YnX|j�ytjd	}	Wntk
r�YnX|	jj
�ytjd
}
Wntk
rYnX|
j�ytjd}Wntk
r2Yn
Xd|_ytjd}Wntk
raYnX|j�ytjd
}
Wntk
r�YnXx|
jD]
}|�q�W|j�dS)Nr�__warningregistry__zdistutils.dir_util�	_strptimezurllib.parsezurllib.request�	linecache�	mimetypes�filecmp�struct�doctest�ctypesr	)r�rtr�valuesrorr�r}�
__stdout__�
__stderr__r��KeyErrorZ
_path_createdr�r��purgeZ_regex_cacheZclear_cache�
urlcleanup�
clearcacheZ_default_mime_types�_cache�_clearcacheZmasterZ_reset_cacheZ	_cleanupsr%)r�r?rXZdistutils_dir_utilrZurllib_parseZurllib_requestrrrrrrr	�frrr	r�Ks�
%

















	


r�cCsmttd��}x&td�D]}|||d�qWdd�td�D�}ttdd��}dS)N�r
cSsg|]}t|��qSr)�chr)rr�rrr	r
�s	zwarm_caches.<locals>.<listcomp>ri���)�bytesr!r)�sr�rSrrr	r��s
r�cCs|ptjjt�ptjS)N)rr�dirnamer�curdir)rrrr	r:�sr:cCsY|s
dSxHt|�D]:\}}tjj|�\}}|dkr|||<qWdS)Nz.py)r$rrr<)r>�idxr��basenamer@rrr	r�srcCs,|dkrd||fSd||fSdS)Nr
z%d %sz%d %ssr)�nZwordrrr	r*�sr*�FcCs_ddlm}d|}t|djdd�t|�D��|d|d|�d|�dS)	Nr)�fillr�css|]}t|�VqdS)N)r�)rZeltrrr	r��szprintlist.<locals>.<genexpr>�initial_indent�subsequent_indentrl)�textwrapr0ryrGr=)rS�width�indentrlr0Zblanksrrr	r(�s
+r(cCs(|jd�s|jr|Sd|SdS)Nztest.)rsr[)r�r�rrr	r��sr�cCs}xv|D]n}t|tjj�r%qt|tj�rDt|�qt|tj�rtj|�rt	|j
��qWdS)N)�
isinstancer�r�Z_FailedTestZ	TestSuite�_list_casesZTestCaserZ_match_testryrp)�suiter�rrr	r7�s

r7cCs�dt_|jt_g}xb|D]Z}t||�}y tjj|�}t|�Wq"tjk
r{|j	|�Yq"Xq"W|r�t
dtj�t
t
t|�d�ddtj�t|dtj�dS)NFrlr�zskipped:)rr\r/r�r�ZdefaultTestLoaderZloadTestsFromNamer7r�r0ryrtr}r*rLr()r�r4r�r�r�r8rrr	r�s	
%rcCs�tj�r2ytjt�Wntk
r1YnXdjtj��}tjj	t|�}t
j|dd��t�WdQRXdS)Nztest_python_{}r]T)
r��is_python_buildr�mkdirr��FileExistsErrorr�r.rrGrZtemp_cwdr8)Ztest_cwdrrr	�main_in_temp_cwd�s
r<�__main__)kr8r9r:r�r;r�r�rxrQr�rlr�rrr
r�r�r�rtr�rr�r�r�r�r��inspectrrr��_multiprocessingZmultiprocessing.processr�rrr7rorrrrZresourceZ	getrlimitZRLIMIT_STACKZsoftZhard�min�maxZnewsoftZ	setrlimitr�r�r�r�r�r�r�r�rr{rXr9rGr�r��
gettempdir�ArgumentParserrrFrBrCrAr�r�r�r8rr	rr�objectr r�r�rPrYrUrWr�rr�r�r:rr*r(r�r7rr<r�normpathr*r�ZmydirrLr�rrrr	�<module>s�
f


	

!}
Y )��		
	H	
�<*U,b
1
+