Your IP : 18.226.166.207


Current Path : /proc/self/root/usr/lib64/python3.6/test/support/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/test/support/__pycache__/__init__.cpython-36.opt-2.pyc

3

�Qg����@sX
edkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z!ddl"Z"ddl#m$Z$yddl%Z%ddl&Z&Wnek
�r>dZ%dZ&YnXyddl'Z(Wnek
�rfdZ(YnXyddl)Z)Wnek
�r�dZ)YnXyddl*Z*Wnek
�r�dZ*YnXyddl+Z+Wnek
�r�dZ+YnXyddl,Z,Wnek
�rdZ,YnXyddl-Z-Wnek
�r.dZ-YnXyddl.Z.Wnek
�rVdZ.YnXdddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dag\Z/Gdbd�de0�Z1Gdcd�de1�Z2Gddd
�d
e1�Z3Gded�dej4�Z5ej6�dedgdh��Z7�dffdj�dkd�Z8dldm�Z9dndo�Z:dpd<�Z;dqd=�Z<ffdifdrd�Z=dsd8�Z>dZ?dZ@daAdaBdZCdiZDdaEdtd�ZFdud�ZGdvd�ZHdwdx�ZIejjJdy��r*�dgdzd{�ZKd|d}�ZLd~d�ZMd�d��ZNd�d��ZOnejPZLejQZMd�d��ZNd�d��ZOd�d�ZPd�d��ZQd�d�ZRd�d��ZSd�d�ZTd�d��ZUd�d"�ZV�dhd�d#�ZWd�d��ZXd�d$�ZYd�d%�ZZd�d&�Z[�did�d'�Z\d�Z]d�Z^ej_ej`fd�dI�Zae]fd�dJ�Zbd�dL�Zcd�d��Zded�Zed�d��Zf�dlZg�doZhejiejjkd��jJd��d��Zlejie)d��Zmejie*d��Znejie+d��Zoejie,d��ZpejjJd��Zqejrd��Zsesdk	�otesdkZtejd�k�r�et�r�d�nd�ZundZuejvd�k�r�d�Zwnd�Zwd�jxewejy��ZwdZzxL�dpD]BZ{yej|ej}e{��e{k�r�e~�Wne~k
�rYnXe{ZzP�q�Wewd�Zejd�k�r6ddl�Z�e�j�d�e�Zej��Z�dZ�ejvd�k�r�ej��jd�k�r�ewd�Z�ye�j�e��Wne�k
�r�YnXe�d�e�e�f�dZ�nBejd�k�r�yd�j�e��Wn&e�k
�r�ewd�j�e�dƃZ�YnXdZ�xF�dqD]<Zvyevj�e��Wn&e�k
�r(ej}ew�evZ�PYnX�q�Wez�rDewd�ezZ�ndZ�ej��Z�diZ�diZ�ej6�drd�d̈́�Z�ej6�dsd�dτ�Z�ej6�dtd�d��Z�e�ed҃�r�ej6d�dM��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�dԃZ��dud�d�Z�d�d�Z�d�d]�Z�d�dلZ�dddڜd�d(�Z�d�dK�Z�Gd�dބd�e��Z��dvd�d�Z�ej6d�dT��Z�ej6d�e�difd�d��Z�ej6d�dU��Z�Gd�d�de��Z�Gd�dV�dVej�j��Z�Gd�d�d�e��Z�Gd�d)�d)e��Z�e�e�ej�d�Z�e�e�ej�d�Z�e�e�ej�d�Z�ej6d�fd�d�d-��Z�ej6d�d��Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej6d�d���Z�d�d��Z�d�Z�d�Z�e�ed���	rHd�e�Z�d�Z�e�d�Z��d�d�Zd�d�ZÐdwZĐdxZŐd�d�ZƐddW�Zǐd	d^�ZȐdyZ�d�e�Z�d�e�Z�d�e�Z�ej�Zΐd
d[�Z�G�d�d��d�ZАdz�d
d5�Zѐdd6�Z�G�dd.�d.�ZӐd�d�ZԐd�d�ZՐdd@�Z֐dd7�Zאd{�d�d�Z�daِddA�Zڐd�d�ZېddD�Zܐd�d�Zݐd�d�Zސd �d!�Zߐd"�d#�Z�da�da�d$�d%�Z�d&�d'�Z�d(�d)�Z�d*d/�Z�d+�d,�Z�e܃�
o�ejd�k�
o�ejr�d-�Z�e�j�dk	�oe�Z�ejie�d.�Z�d|�d/d0�Z�d0�d1�Z�d2�d3�Z�diZ�d4dP�Z�d5dQ�Z�d6dR�Z�ej6�d}�d8�d9��Z�d:dN�Z�ej6�d~�d;dS��Z�ej6�d<dY��Z�ej6�d=dX��Z��d>�d?�Z�ej�e�e�d@��dA�Z��dB�dC�Z��dD�dE�Z�G�dFdO�dOej�j��Z�G�dGdZ�dZe���Zd�a�dHd ��Z�dId1��Zd�a�dJ�dK��Z�dLd:��Z�dM�dN��Z�dOd!��Zf�dP��dQd>��Z	dfff�dRd?��Z
G�dSd\�d\��Z�dT�dU��Z�dV�dW��Z
ff�dX�dY��Zgf�dZd`��Zd�a�d[dF��Zej6�d\�d]���Z�d^da��ZG�d_�d`��d`��ZG�da�db��db��Zej6�dc�dd���ZdS(ztest.supportz.support must be imported from the test package�N�)�get_test_runner�
PIPE_MAX_SIZE�verbose�
max_memuse�
use_resources�failfast�Error�
TestFailed�
TestDidNotRun�ResourceDenied�
import_module�import_fresh_module�CleanImport�unload�forget�record_original_stdout�get_original_stdout�captured_stdout�captured_stdin�captured_stderr�TESTFN�SAVEDCWD�unlink�rmtree�temp_cwd�findfile�create_empty_file�can_symlink�fs_is_case_insensitive�is_resource_enabled�requires�requires_freebsd_version�requires_linux_version�requires_mac_ver�requires_hashdigest�check_syntax_error�TransientResource�time_out�socket_peer_reset�ioerror_peer_reset�transient_internet�BasicTestRunner�run_unittest�run_doctest�skip_unless_symlink�
requires_gzip�requires_bz2�
requires_lzma�
bigmemtest�bigaddrspacetest�cpython_only�
get_attribute�requires_IEEE_754�skip_unless_xattr�
requires_zlib�anticipate_failure�load_package_tests�detect_api_mismatch�check__all__�requires_android_level�requires_multiprocessing_queue�	is_jython�
is_android�check_impl_detail�
unix_shell�setswitchinterval�HOST�IPV6_ENABLED�find_unused_port�	bind_port�open_urlresource�bind_unix_socket�
temp_umask�
reap_children�TestHandler�threading_setup�threading_cleanup�reap_threads�
start_threads�check_warnings�check_no_resource_warning�EnvironmentVarGuard�run_with_locale�	swap_item�	swap_attr�Matcher�set_memlimit�SuppressCrashReport�sortdict�run_with_tz�PGO�missing_compiler_executable�fd_countc@seZdZdS)r	N)�__name__�
__module__�__qualname__�rcrc�-/usr/lib64/python3.6/test/support/__init__.pyr	|sc@seZdZdS)r
N)r`rarbrcrcrcrdr
sc@seZdZdS)rN)r`rarbrcrcrcrdr�sc@seZdZdS)rN)r`rarbrcrcrcrdr�sTccs8|r.tj��tjddt�dVWdQRXndVdS)N�ignorez.+ (module|package))�warnings�catch_warnings�filterwarnings�DeprecationWarning)rercrcrd�_ignore_deprecated_imports�s
rjF)�required_oncCsft|��Ty
tj|�Stk
rV}z&tjjt|��r8�tj	t
|���WYdd}~XnXWdQRXdS)N)rj�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedrk�msgrcrcrdr
�s	

cCs^|tjkrt|�tj|=x>ttj�D]0}||ks@|j|d�r&tj|||<tj|=q&WdS)N�.)rn�modules�
__import__�listrp)ru�orig_modules�modnamercrcrd�_save_and_remove_module�s
r~cCs>d}ytj|||<Wntk
r.d}YnXdtj|<|S)NTF)rnry�KeyError)rur|Zsavedrcrcrd�_save_and_block_module�s

r�cCs|r
tjSdd�S)NcSs|S)Nrc)�frcrcrd�<lambda>�sz$anticipate_failure.<locals>.<lambda>)rrZexpectedFailure)Z	conditionrcrcrdr:�scCsF|dkrd}tjjtjjtjjt���}|j|||d�}|j|�|S)Nztest*)Z	start_dirZ
top_level_dir�pattern)�os�path�dirname�__file__ZdiscoverZaddTests)Zpkg_dir�loaderZstandard_testsr�Ztop_dirZ
package_testsrcrcrdr;�s
cCs�t|���i}g}t||�zfyHx|D]}t||�q&Wx |D]}t||�s>|j|�q>Wtj|�}Wntk
r~d}YnXWdx|j�D]\}	}
|
tj	|	<q�Wx|D]}tj	|=q�WX|SQRXdS)N)
rjr~r��appendrlr
rm�itemsrnry)ruZfreshZblockedrvr|Znames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removercrcrdr�s$





cCs>yt||�}Wn&tk
r4tjd||f��YnX|SdS)Nzobject %r has no attribute %r)�getattr�AttributeErrorrrrs)�objruZ	attributercrcrdr6s
cCs|adS)N)�_original_stdout)�stdoutrcrcrdr0scCs
tptjS)N)r�rnr�rcrcrcrdr4scCs&ytj|=Wntk
r YnXdS)N)rnryr)rurcrcrdr7scGsny||�Stk
rh}zDtdkrHtd|jj|f�td|j|f�tj|tj�||�Sd}~XnXdS)N�z%s: %szre-run %s%r)	�OSErrorr�print�	__class__r`r��chmod�stat�S_IRWXU)r��func�args�errrcrcrd�
_force_run=sr��wincCs�||�|r|}ntjj|�\}}|p(d}d}x<|dkrjtj|�}|rJ|n||ksVdStj|�|d9}q0Wtjd|tdd�dS)Nrxg����MbP?g�?r�z)tests may fail, delete still pending for �)�
stacklevel)	r�r��split�listdir�time�sleeprf�warn�RuntimeWarning)r��pathname�waitallr�ru�timeout�Lrcrcrd�_waitforHs



r�cCsttj|�dS)N)r�r�r)�filenamercrcrd�_unlinkisr�cCsttj|�dS)N)r�r��rmdir)r�rcrcrd�_rmdirlsr�cs,�fdd��t�|dd�tdd�|�dS)Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wn<tk
rn}z td||ft	j
d�d}WYdd}~XnXtj|�r�t
�|dd�t|tj|�qt|tj|�qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)�filerT)r�)r�r�r�r��join�lstat�st_moder�r�rn�
__stderr__r��S_ISDIRr�r�r)r�ru�fullname�mode�exc)�
_rmtree_innerrcrdr�ps

z_rmtree.<locals>._rmtree_innerT)r�cSst|tj|�S)N)r�r�r�)�prcrcrdr�sz_rmtree.<locals>.<lambda>)r�)r�rc)r�rd�_rmtreeosr�c
Cs^yddl}Wntk
r Yn:X|jt|�d�}|jjj||t|��}|rZ|d|�S|S)Nrr�)�ctypesrmZcreate_unicode_buffer�len�windll�kernel32ZGetLongPathNameW)r�r��bufferZlengthrcrcrd�	_longpath�s
r�csFytj|�dStk
r"YnX�fdd���|�tj|�dS)Nc
s�x~t|tj|�D]l}tjj||�}ytj|�j}Wntk
rJd}YnXtj	|�rn�|�t|tj
|�qt|tj|�qWdS)Nr)r�r�r�r�r�r�r�r�r�r�r�r)r�rur�r�)r�rcrdr��s

z_rmtree.<locals>._rmtree_inner)�shutilrr�r�r�)r�rc)r�rdr��s
cCs|S)Nrc)r�rcrcrdr��scCs*yt|�Wnttfk
r$YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rcrcrdr�scCs&yt|�Wntk
r YnXdS)N)r�r�)r�rcrcrdr��sr�cCs&yt|�Wntk
r YnXdS)N)r�r�)r�rcrcrdr�scCsBtjj|�}tjjtjj|��}tjj||d�}tj||�|S)N�c)	rl�util�cache_from_sourcer�r�r��abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrcrcrd�make_legacy_pyc�s
r�cCs\t|�xNtjD]D}tjj||d�}t|d�x dD]}ttjj||d��q8WqWdS)Nz.pyr��rr�)�optimization)r�rr�)	rrnr�r�r�rrlr�r�)r}r�r��optrcrcrdr�s
cs�ttd�rtjSd}tjjd�r�ddl�ddl�d}d}G�fdd�d�j�}�j	j
}|j�}|sj�j��|�}�j
j�}|j||�j|��j|��j|��}|s��j��t|j|@�s�d}n�tjdk�rVdd	lm}	m�m}
m}dd
lm}|	j|d��}
|
j�dk�rd}nFG�fd
d�d|�}|�}|
|�}|
j|�dk�sR|
j|�dk�rVd}|�s�y.ddlm}|�}|j�|j �|j!�Wn\t"k
�r�}z>t#|�}t$|�dk�r�|dd�d}dj%t&|�j'|�}WYdd}~XnX|t_(|t_tjS)N�resultr�rrcs.eZdZd�jjfd�jjfd�jjfgZdS)z*_is_gui_available.<locals>.USEROBJECTFLAGSZfInheritZ	fReserved�dwFlagsN)r`rarb�wintypesZBOOL�DWORD�_fields_rc)r�rcrd�USEROBJECTFLAGS�s

r�z,gui not available (WSF_VISIBLE flag not set)�darwin)�cdll�c_int�pointer�	Structure)�find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZd�fd�fgZdS)z._is_gui_available.<locals>.ProcessSerialNumberZ
highLongOfPSNZlowLongOfPSNN)r`rarbr�rc)r�rcrd�ProcessSerialNumbersr�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rnrorpr�Zctypes.wintypesr�r�Zuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr�Zwithdraw�updateZdestroy�	Exceptionrtr��format�typer`�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrc)r�r�rdr��sh

r�cCstdkp|tkS)N)r)�resourcercrcrdr $scCs>t|�s |dkrd|}t|��|dkr:t�r:ttj��dS)Nz"Use of the %r resource not enabled�gui)r rr�r�)r�rwrcrcrdr!,scs��fdd�}|S)Ncs$tj�����fdd��}�|_|S)Nc
s�tj��krztj�jdd�d}yttt|jd���}Wntk
rLYn.X|�krzdjtt	���}t
jd�||f���||�S)N�-rrrxz(%s version %s or higher required, not %s)ro�system�releaser�rq�map�int�
ValueErrorr�rtrrrs)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamercrd�wrapper=sz:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�rd�	decorator<sz)_requires_unix_version.<locals>.decoratorrc)r�r�r�rc)r�r�rd�_requires_unix_version5sr�cGs
td|�S)NZFreeBSD)r�)r�rcrcrdr"PscGs
td|�S)NZLinux)r�)r�rcrcrdr#Yscs�fdd�}|S)Ncs"tj����fdd��}�|_|S)Ncsxtjdkrntj�d}yttt|jd���}Wntk
rBYn,X|�krndjtt	���}t
jd||f���||�S)Nr�rrxz&Mac OS X %s or higher required, not %s)rnroZmac_verrqr�r�r�r�r�rtrrrs)r�r�r�r�r�)r�r�rcrdr�js
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rdr�isz#requires_mac_ver.<locals>.decoratorrc)r�r�rc)r�rdr$bscs��fdd�}|S)Ncstj�����fdd��}|S)NcsXy&�rtdk	rtj��n
tj��Wn&tk
rLtjd��d���YnX�||�S)Nz
hash digest 'z' is not available.)�_hashlib�new�hashlibr�rrrs)r��kwargs)�
digestnamer��opensslrcrdr��sz7requires_hashdigest.<locals>.decorator.<locals>.wrapper)r�r�)r�r�)r�r)r�rdr��sz&requires_hashdigest.<locals>.decoratorrc)r�rr�rc)r�rrdr%}s
z	127.0.0.1z::1cCs"tj||�}t|�}|j�~|S)N)�socketrH�close)�familyZsocktypeZtempsock�portrcrcrdrG�s
8cCs�|jtjkr�|jtjkr�ttd�r>|jtjtj�dkr>t	d��ttd�r~y |jtjtj
�dkrft	d��Wntk
r|YnXttd�r�|jtjtj
d�|j|df�|j�d}|S)N�SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)rr�AF_INETr��SOCK_STREAMr�Z
getsockoptZ
SOL_SOCKETrr
rr�Z
setsockoptr�bindZgetsockname)�sock�hostrrcrcrdrH�s


cCs:y|j|�Wn&tk
r4|j�tjd��YnXdS)Nzcannot bind AF_UNIX sockets)r
�PermissionErrorrrrrs)rZaddrrcrcrdrJs
cCsZtjrVd}z<y"tjtjtj�}|jtdf�dStk
rBYnXWd|rT|j�XdS)NrTF)rZhas_ipv6ZAF_INET6r	r
�HOSTv6r�r)rrcrcrd�_is_ipv6_enableds

rcstj���fdd��}|S)NcsNy�||�Wn:tk
rH}zdt|�kr6tjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrtrrrs)r�r�r�)r�rcrd�decs
z&system_must_validate_cert.<locals>.dec)r�r�)r�rrc)r�rd�system_must_validate_certs	rr�i�ZdoubleZIEEEztest requires IEEE 754 doublesz
requires zlibz
requires gzipzrequires bz2z
requires lzma�java�ANDROID_API_LEVEL�win32z/system/bin/shz/bin/shz$testz@testz	{}_{}_tmp�æ�İ�Ł�φ�К�א�،�ت�ก� �€u-àòɘŁğr�ZNFD�ntr�u-共Ł♡ͣ�ztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effective��s-��surrogateescape��w����������r�ccs�d}|dkr&tj�}d}tjj|�}nBytj|�d}Wn.tk
rf|sN�tjd|t	dd�YnX|rttj
�}z
|VWd|r�|tj
�kr�t|�XdS)NFTz+tests may fail, unable to create temp dir: �)r�)�tempfile�mkdtempr�r��realpath�mkdirr�rfr�r��getpidr)r��quietZdir_created�pidrcrcrd�temp_dir�s&


r1ccsftj�}ytj|�Wn.tk
rD|s,�tjd|tdd�YnXztj�VWdtj|�XdS)Nz)tests may fail, unable to change CWD to: r))r�)r��getcwd�chdirr�rfr�r�)r�r/Z	saved_dirrcrcrd�
change_cwd	s

r4�tempcwdccs:t||d��$}t||d��}|VWdQRXWdQRXdS)N)r�r/)r/)r1r4)rur/Z	temp_pathZcwd_dirrcrcrdr$s�umaskccs&tj|�}z
dVWdtj|�XdS)N)r�r6)r6ZoldmaskrcrcrdrK8s

�datacCsbtjj|�r|S|dk	r&tjj||�}tgtj}x*|D]"}tjj||�}tjj|�r8|Sq8W|S)N)r�r��isabsr��
TEST_HOME_DIRrn�exists)r�Zsubdirr�Zdn�fnrcrcrdrIs
cCs(tj|tjtjBtjB�}tj|�dS)N)r��open�O_WRONLY�O_CREAT�O_TRUNCr)r��fdrcrcrdr[scCs,t|j��}dd�|D�}dj|�}d|S)NcSsg|]}d|�qS)z%r: %rrc)�.0Zpairrcrcrd�
<listcomp>cszsortdict.<locals>.<listcomp>z, z{%s})�sortedr�r�)�dictr�Z	reprpairsZ
withcommasrcrcrdr[`s
cCs*ttd�}z|j�S|j�tt�XdS)N�wb)r<r�filenorr)r�rcrcrd�make_bad_fdgs

rG)�lineno�offsetcCsp|jt��}t|dd�WdQRX|j}|j|j�|dk	rJ|j|j|�|j|j�|dk	rl|j|j|�dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compileZ	exceptionZassertIsNotNonerH�assertEqualrI)�testcaseZ	statementrHrI�cmr�rcrcrdr&sscsVddl}ddl}�jdd��|jj|�djd�d}tjjt	|�}���fdd�}tjj
|�r|||�}|dk	rt|St|�td�t
r�td	|t�d
�|jj�}tr�|jjd�|j|d
d�}tr�|jjd�dkr�tj|d�}zBt|d��.}	|j�}
x|
�r|	j|
�|j�}
�q�WWdQRXWd|j�X||�}|dk	�rF|Std|��dS)Nr�checkr��/rcs>t|f����}�dkr|S�|�r2|jd�|S|j�dS)Nr)r<�seekr)r;r�)r�rQr�rcrd�check_valid_file�s
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...)r��Accept-Encoding�gzip�)r�zContent-Encoding)ZfileobjrEzinvalid resource %r���)rUrV)Zurllib.requestZurllib.parse�pop�parseZurlparser�r�r�r��
TEST_DATA_DIRr:rr!rr�rZrequestZbuild_openerrVZ
addheadersr�r<Zheaders�getZGzipFile�read�writerr
)Zurlr�r��urllibr�r;rTr��opener�out�src)r�rQr�rdrI~s<	



c@s0eZdZdd�Zdd�Zedd��Zdd�Zd	S)
�WarningsRecordercCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrcrcrd�__init__�szWarningsRecorder.__init__cCsDt|j�|jkr t|jd|�S|tjjkr0dStd||f��dS)Nrz%r has no attribute %rrX)r�rdrer�rf�WarningMessage�_WARNING_DETAILSr�)rf�attrrcrcrd�__getattr__�s
zWarningsRecorder.__getattr__cCs|j|jd�S)N)rdre)rfrcrcrdrf�szWarningsRecorder.warningscCst|j�|_dS)N)r�rdre)rfrcrcrd�reset�szWarningsRecorder.resetN)r`rarbrgrk�propertyrfrlrcrcrcrdrc�srcc
cs
tjd�}|jjd�}|r"|j�tjdd�� }tjdjd�t	|�VWdQRXt
|�}g}xz|D]r\}}d}	xH|dd�D]8}|j}
tj
|t|
�tj�r�t|
j|�r�d}	|j|�q�W|	rf|rf|j||jf�qfW|r�td|d	��|�rtd
|d	��dS)Nr�Z__warningregistry__T)�recordrf�alwaysFzunhandled warning %srz)filter (%r, %s) did not catch any warning)rn�	_getframe�	f_globalsr\�clearrfrgry�simplefilterrcr{�message�re�matchrt�I�
issubclassr��remover�r`�AssertionError)�filtersr/�frame�registry�wZreraiseZmissingrw�cat�seenZwarningrcrcrd�_filterwarnings�s0
r�cOs.|jd�}|s$dtff}|dkr$d}t||�S)Nr/r�T)r\�Warningr�)r{r�r/rcrcrdrR�s

r�ccsHtjdd��&}tjd||d�dV|r.t�WdQRX|j|g�dS)NT)rnro)rt�category)rfrgrh�
gc_collectrN)rOrtr�Zforce_gc�warnsrcrcrd�check_no_warningssr�ccsBtjdd�� }tjdtd�dVt�WdQRX|j|g�dS)NT)rnro)r�)rfrgrh�ResourceWarningr�rN)rOr�rcrcrdrSs
c@s$eZdZdd�Zdd�Zdd�ZdS)rcGsNtjj�|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rnry�copy�original_modulesr`)rfZmodule_namesZmodule_namer�rcrcrdrg?s




zCleanImport.__init__cCs|S)Nrc)rfrcrcrd�	__enter__LszCleanImport.__enter__cGstjj|j�dS)N)rnryr�r�)rf�
ignore_excrcrcrd�__exit__OszCleanImport.__exit__N)r`rarbrgr�r�rcrcrcrdr3s
c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rTcCstj|_i|_dS)N)r��environ�_environ�_changed)rfrcrcrdrgXszEnvironmentVarGuard.__init__cCs
|j|S)N)r�)rf�envvarrcrcrd�__getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj|�|j|<||j|<dS)N)r�r�r\)rfr��valuercrcrd�__setitem___s
zEnvironmentVarGuard.__setitem__cCs2||jkr|jj|�|j|<||jkr.|j|=dS)N)r�r�r\)rfr�rcrcrd�__delitem__es

zEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rfrcrcrdr�lszEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rfrcrcrd�__iter__oszEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rfrcrcrd�__len__rszEnvironmentVarGuard.__len__cCs|||<dS)Nrc)rfr�r�rcrcrd�setuszEnvironmentVarGuard.setcCs
||=dS)Nrc)rfr�rcrcrd�unsetxszEnvironmentVarGuard.unsetcCs|S)Nrc)rfrcrcrdr�{szEnvironmentVarGuard.__enter__cGsJx<|jj�D].\}}|dkr0||jkr:|j|=q||j|<qW|jt_dS)N)r�r�r�r�r�)rfr��k�vrcrcrdr�~s

zEnvironmentVarGuard.__exit__N)r`rarbrgr�r�r�r�r�r�r�r�r�r�rcrcrcrdrTSsc@s$eZdZdd�Zdd�Zdd�ZdS)�
DirsOnSysPathcGs(tjdd�|_tj|_tjj|�dS)N)rnr��original_value�original_object�extend)rf�pathsrcrcrdrg�szDirsOnSysPath.__init__cCs|S)Nrc)rfrcrcrdr��szDirsOnSysPath.__enter__cGs|jt_|jtjdd�<dS)N)r�rnr�r�)rfr�rcrcrdr��szDirsOnSysPath.__exit__N)r`rarbrgr�r�rcrcrcrdr��sr�c@s&eZdZdd�Zdd�Zddd�ZdS)	r'cKs||_||_dS)N)r��attrs)rfr�r�rcrcrdrg�szTransientResource.__init__cCs|S)Nrc)rfrcrcrdr��szTransientResource.__enter__NcCsT|dk	rPt|j|�rPx:|jj�D]$\}}t||�s4Pt||�|kr Pq Wtd��dS)Nz%an optional resource is not available)rxr�r�r�r�r�r)rfZtype_r��	tracebackrjZ
attr_valuercrcrdr��s
zTransientResource.__exit__)NNN)r`rarbrgr�r�rcrcrcrdr'�s)�errnog>@)r��errnosc	#spd d!d"d#d$d%g}d'd)d+d-d.g}td|��|�g��sRdd�|D��dd�|D�����fdd�}tj�}z�y|dk	r�tj|�dVWn�tjk
�r�}z&tr�tjj	�j
dd��|�WYdd}~Xn�tk
�rZ}zpx^|j
}t|�dk�rt
|dt��r|d}n*t|�dk�r8t
|dt��r8|d}nP�q�W||��WYdd}~XnXWdtj|�XdS)/N�ECONNREFUSED�o�
ECONNRESET�h�EHOSTUNREACH�q�ENETUNREACH�e�	ETIMEDOUT�n�
EADDRNOTAVAIL�c�	EAI_AGAINr)�EAI_FAILr��
EAI_NONAMEr��
EAI_NODATA��
WSANO_DATA�*zResource %r is not availablecSsg|]\}}tt||��qSrc)r�r�)rAru�numrcrcrdrB�sz&transient_internet.<locals>.<listcomp>cSsg|]\}}tt||��qSrc)r�r)rArur�rcrcrdrB�scs�t|dd�}t|tj�s�t|tj�r,|�ks�t|tjj�rTd|jkoNdkns�t|tjj	�r�d|j
ks�d|j
ks�d|j
ks�|�kr�ts�tj
j�jdd��|�dS)	Nr�i�iW�ConnectionRefusedError�TimeoutError�EOFErrorr�
)r��
isinstancerr�Zgaierrorr_�errorZ	HTTPError�codeZURLErrorr�rrn�stderrr^r�)r��n)�captured_errnos�denied�
gai_errnosrcrd�filter_error�s


z(transient_internet.<locals>.filter_errorrr�r)r�r�)r�r�)r�r�)r�r�)r�r�)r�r����)r�r����)r�r����)r�r����)r�r�)r�r�)rrZgetdefaulttimeoutZsetdefaulttimeout�nntplibZNNTPTemporaryErrorrrnr�r^r�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��arc)r�r�r�rdr+�sP



c
csFddl}tt|�}tt||j��ztt|�VWdtt||�XdS)Nr)�ior�rn�setattr�StringIO)Zstream_namer�Zorig_stdoutrcrcrd�captured_outputs
r�cCstd�S)Nr�)r�rcrcrcrdrscCstd�S)Nr�)r�rcrcrcrdr%scCstd�S)N�stdin)r�rcrcrcrdr.s
cCs*tj�trtjd�tj�tj�dS)Ng�������?)�gcZcollectr@r�r�rcrcrcrdr�;s


r�c
cs.tj�}tj�z
dVWd|r(tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrcrcrd�
disable_gcKs
r�cCs:tjd�pd}d}x|j�D]}|jd�r|}qW|dkS)N�	PY_CFLAGSr�z-O�-O0�-Og)r�r�r�)�	sysconfig�get_config_varr�rp)ZcflagsZ	final_optr�rcrcrd�python_is_optimizedVs
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrcrcrd�calcobjsizegsr�cCstjt|t�S)N)r�r��_vheaderr�)r�rcrcrd�calcvobjsizejsr���	cCspddl}tj|�}t|�tkr(|jt@sBt|�tkrLt|�jt@rL||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapirn�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrN)�test�o�sizer�r�rwrcrcrd�check_sizeofqs

r�cs��fdd�}|S)Ncs$���fdd�}�j|_�j|_|S)Ncs�y ddl}t|��}|j|�}Wn(tk
r6�YnBd}}Yn0Xx,�D]$}y|j||�PWqPYqPXqPWz
�||�S|r�|r�|j||�XdS)Nr)�localer��	setlocaler�)r��kwdsr�r�Zorig_locale�loc)�catstrr��localesrcrd�inner�s$



z1run_with_locale.<locals>.decorator.<locals>.inner)r`�__doc__)r�r�)r�r�)r�rdr��sz"run_with_locale.<locals>.decoratorrc)r�r�r�rc)r�r�rdrU�scs�fdd�}|S)Ncs"��fdd�}�j|_�j|_|S)Ncs�y
tj}Wntk
r(tjd��YnXdtjkr@tjd}nd}�tjd<|�z
�||�S|dkrrtjd=n
|tjd<tj�XdS)Nztzset requiredZTZ)r��tzsetr�rrrsr�r�)r�r�r�Zorig_tz)r��tzrcrdr��s





z-run_with_tz.<locals>.decorator.<locals>.inner)r`r�)r�r�)r�)r�rdr��szrun_with_tz.<locals>.decoratorrc)r�r�rc)r�rdr\�scCs�dttdtd�}tjd|tjtjB�}|dkr>td|f��tt|j	d��||j	d�j
��}|a|tkrrt}|t
dkr�td|f��|adS)Ni)r��m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr)z$Memory limit %r too low to be useful)�_1M�_1Grurv�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr�ZmemlimitrcrcrdrY�s$c@s$eZdZdd�Zdd�Zdd�ZdS)�_MemoryWatchdogcCsdjtj�d�|_d|_dS)Nz/proc/{pid}/statm)r0F)r�r�r.�procfile�started)rfrcrcrdrg�sz_MemoryWatchdog.__init__cCs�yt|jd�}Wn<tk
rL}z tjdj|�t�tjj	�dSd}~XnXt
d�}tjtj
|g|tjd�|_|j�d|_dS)N�rz!/proc not available for stats: {}zmemory_watchdog.py)r�r�T)r<r
r�rfr�r�r�rnr��flushr�
subprocess�Popen�
executableZDEVNULL�mem_watchdogrr)rfr�r�Zwatchdog_scriptrcrcrd�start�s
z_MemoryWatchdog.startcCs|jr|jj�|jj�dS)N)rrZ	terminate�wait)rfrcrcrd�stop�s
z_MemoryWatchdog.stopN)r`rarbrgrrrcrcrcrdr	�sr	cs���fdd�}|S)Ncs ���fdd����_��_�S)Nc
s��j}�j}tsd}n|}ts$�rFt||krFtjd||d��tr|tr|t�tdj||dd��t�}|j	�nd}z
�||�S|r�|j
�XdS)	Niz'not enough memory: %.1fG minimum neededir)z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@)r��memuserrrrsrr�r�r	rr)rfr�r�maxsizeZwatchdog)�dry_runr�r�rcrdr�s*


z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)r�)rrr�)r�r�rdr�szbigmemtest.<locals>.decoratorrc)r�rrr�rc)rrr�rdr3s
!cs�fdd�}|S)NcsDttkr8td
kr$tdkr$tjd��q@tjdtd��n�|�SdS)
Nr��?r�z-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir)ll����li@)rrrrrs)rf)r�rcrdr�3sz!bigaddrspacetest.<locals>.wrapperrc)r�r�rc)r�rdr41sc@seZdZdd�ZdS)r,cCstj�}||�|S)N)rrZ
TestResult)rfr�r�rcrcrd�runDszBasicTestRunner.runN)r`rarbrrcrcrcrdr,CscCs|S)Nrc)r�rcrcrd�_idIsrcCs<|dkrt�rtjtj�St|�r(tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�rr�skipr�r rr�)r�rcrcrd�requires_resourceLs
rcCs&trt|krtjd|tf�StSdS)Nz%s at Android API level %d)rA�_ANDROID_API_LEVELrrrr)�levelr�rcrcrdr>TscCstdd�|�S)NT)�cpython)�impl_detail)r�rcrcrdr5[scKsVtf|�rtS|dkrLt|�\}}|r,d}nd}t|j��}|jdj|��}tj|�S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or )	rBr�
_parse_guardsrCr�r�r�rrr)rw�guardsZ
guardnames�defaultrcrcrdr!as
r!cCsTtdkr:ddl}y|j�daWntk
r8daYnXd}trF|Stj|�|�S)NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessingZQueuermrrr)r�r&rwrcrcrdr?os
cCs*|sddidfSt|j��d}||fS)Nr TFr)r{�values)r#Zis_truercrcrdr"~sr"cKs t|�\}}|jtj�j�|�S)N)r"r\roZpython_implementationr)r#r$rcrcrdrB�scs,ttd�s�Stj���fdd��}|SdS)N�gettracecs.tj�}ztjd��||�Stj|�XdS)N)rnr(�settrace)r�r�Zoriginal_trace)r�rcrdr��s


zno_tracing.<locals>.wrapper)r�rnr�r�)r�r�rc)r�rd�
no_tracing�s
r*cCstt|��S)N)r*r5)r�rcrcrd�
refcount_test�sr+cCsRg}xB|jD]8}t|tj�r2t||�|j|�q||�r|j|�qW||_dS)N)Z_testsr�rr�	TestSuite�
_filter_suiter�)�suiteZpredZnewtestsr�rcrcrdr-�s
r-cCs�ttjttdk	d�}|j|�}tdk	r4tj|j��|js>t	�|j
�s�t|j�dkrl|j
rl|jdd}n6t|j
�dkr�|jr�|j
dd}nd}ts�|d7}t|��dS)N)�	verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rrnr�r�junit_xml_listrr�Zget_xml_elementZtestsRunrZ
wasSuccessfulr��errorsZfailuresr
)r.Zrunnerr�r�rcrcrd�
_run_suite�s"
r2cCstdkrdSt|j��SdS)NT)�_match_test_func�id)r�rcrcrd�
match_test�sr5cCsd|kotjd|�S)Nrxz[?*\[\]])ru�search)r�rcrcrd�_is_full_match_test�sr7csr|tkrdS|sd}f}nHttt|��r4t|�j}n.djttj|��}t	j
|�j��fdd�}|}t|�a|a
dS)N�|cs$�|�rdStt�|jd���SdS)NTrx)�anyr�r�)Ztest_id)�regex_matchrcrd�match_test_regex�sz)set_match_tests.<locals>.match_test_regex)�_match_test_patterns�allr�r7r��__contains__r��fnmatch�	translaterurMrvrqr3)Zpatternsr�Zregexr;rc)r:rd�set_match_tests�srAcGs�tjtjf}tj�}xh|D]`}t|t�rT|tjkrJ|jtjtj|��qzt	d��qt||�rj|j|�q|jtj
|��qWt|t�t
|�dS)Nz)str arguments must be keys in sys.modules)rrr,ZTestCaser�rtrnryZaddTestZ
findTestCasesr�Z	makeSuiter-r5r2)�classesZvalid_typesr.�clsrcrcrdr-s





cCsdS)Nrcrcrcrcrd�_check_docstrings(srD�WITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d�\}}|rBtd||f��trXtd|j|f�||fS)Nr)r�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestrZtestmodr
r�r`)r�r/rFrGr�r�rcrcrdr.9scCstjj�fS)N)rnryr�rcrcrcrd�
modules_setupTsrHcCs:dd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs"g|]\}}|jd�r||f�qS)z
encodings.)rp)rAr�r�rcrcrdrB[sz#modules_cleanup.<locals>.<listcomp>)rnryr�rrr�)Z
oldmodulesZ	encodingsrcrcrd�modules_cleanupWs
rIcCs"trtj�tjj�fSdffSdS)Nr)�_thread�_count�	threading�	_danglingr�rcrcrcrdrNzscGsJtsdSd}x8t|�D],}tj�tjf}||kr2Ptjd�t�qWdS)N�dg{�G�z�?)rJ�rangerKrLrMr�r�r�)Zoriginal_valuesZ
_MAX_COUNT�countr'rcrcrdrO�s
cs"ts�Stj���fdd��}|S)Ncst�}z�|�St|�XdS)N)rNrO)r��key)r�rcrdr��szreap_threads.<locals>.decorator)rJr�r�)r�r�rc)r�rdrP�s�N@ccs�tj�}z
dVWdtj�}||}xjtj�}||kr8Ptj�|kr|tj�|}d||�d|d�d|�d|�d�	}t|��tjd�t�q&WXdS)Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z
, old count: �)g{�G�z�?)rJrKr�Z	monotonicrzr�r�)r�Z	old_countZ
start_timeZdeadlinerPZdtrwrcrcrd�wait_threads_exit�s
$
rTc
CsZttd�rVd}xFy2tj|tj�\}}|dkr.Ptd|tjd�WqPYqXqWdS)N�waitpidrrz2Warning -- reap_children() reaped child process %s)r�rX)r�r�rU�WNOHANGr�rnr�)Zany_processr0ZstatusrcrcrdrL�s
ccs*t|�}g}zZy$x|D]}|j�|j|�qWWn*trVtdt|�t|�f��YnXdVWdz�|rt|�tj�}}xltdd�D]^}|d7}x$|D]}|jt	|tj�d��q�Wdd�|D�}|s�Ptr�tdt|�|f�q�WWdd	d�|D�}|�r"t
jtj
�td
t|���XXdS)Nz/Can't start %d threads, only %d threads startedrr�<g{�G�z�?cSsg|]}|j�r|�qSrc)�isAlive)rAr�rcrcrdrB�sz!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSsg|]}|j�r|�qSrc)rX)rAr�rcrcrdrB�szUnable to join %d threads)r{rr�rr�r�r�rOr��max�faulthandlerZdump_tracebackrnr�rz)ZthreadsZunlockrr�ZendtimeZ	starttimer�rcrcrdrQ�s>


c
csnt||�r<t||�}t|||�z
|VWdt|||�Xn.t|||�z
dVWdt||�rht||�XdS)N)r�r�r��delattr)r�rj�new_val�real_valrcrcrdrW�s




ccsX||kr0||}|||<z
|VWd|||<Xn$|||<z
dVWd||krR||=XdS)Nrc)r��itemr\r]rcrcrdrV	s

cCstjdd|�j�}|S)Ns\[\d+ refs, \d+ blocks\]\r?\n?�)ru�sub�strip)r�rcrcrd�strip_python_stderr8	srbZ	getcountsz-types are immortal if COUNT_ALLOCS is definedcCstj�S)N)rZ_args_from_interpreter_flagsrcrcrcrd�args_from_interpreter_flagsE	srccCstj�S)N)rZ"_optim_args_from_interpreter_flagsrcrcrcrd�!optim_args_from_interpreter_flagsJ	srdc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rMcCstjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerrg�matcher)rfrhrcrcrdrgT	szTestHandler.__init__cCsdS)NFrc)rfrcrcrd�shouldFlush]	szTestHandler.shouldFlushcCs|j|�|jj|j�dS)N)r�r�r��__dict__)rfrnrcrcrd�emit`	s
zTestHandler.emitcKs.d}x$|jD]}|jj|f|�rd}PqW|S)NFT)r�rh�matches)rfr�r��drcrcrdrld	szTestHandler.matchesN)r`rarbrgrirkrlrcrcrcrdrMS	s	c@s eZdZdZdd�Zdd�ZdS)	rXrwrtcKs<d}x2|D]*}||}|j|�}|j|||�s
d}Pq
W|S)NTF)r\�match_value)rfrmr�r�r�r��dvrcrcrdrls	s

zMatcher.matchescCsHt|�t|�krd}n.t|�tk	s,||jkr6||k}n|j|�dk}|S)NFr)r�rt�_partial_matches�find)rfr�ror�r�rcrcrdrn�	s
zMatcher.match_valueN)rwrt)r`rarbrprlrnrcrcrcrdrXo	sc
CsZtdk	rtStd}ytjt|�d}Wntttfk
rFd}YnXtj|�|a|S)NrTF)�_can_symlinkrr��symlinkr��NotImplementedErrorr�ry)Zsymlink_path�canrcrcrdr�	s

cCs t�}d}|r|Stj|�|�S)Nz*Requires functional symlink implementation)rrrr)r��okrwrcrcrdr/�	scCs�tdk	rtSttd�sd}n�tj�}tj|d�\}}z�ttd���}y`tj|dd�tj|dd�tj|j	�dd�t
j�}tj
d	|�}|dkp�t|jd
��dk}Wntk
r�d}YnXWdQRXWdtt�t|�t|�X|a|S)N�setxattrF)�dirrEs	user.testr_strusted.foos42z
2.6.(\d{1,2})r�')�
_can_xattrr�r�r*r+Zmkstempr<rrwrFror�rurvr�rr�rr�)ruZtmp_dirZtmp_fpZtmp_name�fpZkernel_versionr�rcrcrd�	can_xattr�	s,

r|cCs t�}d}|r|Stj|�|�S)Nz(no non-broken extended attribute support)r|rrr)r�rvrwrcrcrdr8�	scCs$tpt}d}|r|Stj|�|�S)Nz#Not run for (non-extended) PGO task)r]�PGO_EXTENDEDrrr)r�rvrwrcrcrd�skip_if_pgo_task�	s
r~cCs^tj|d��H}|j}|j�}||kr,|j�}ytjj||�Stk
rNdSXWdQRXdS)N)rxF)	r*ZNamedTemporaryFileru�upperrr�r��samefiler�)Z	directory�base�	base_pathZ	case_pathrcrcrdr�	s)recCs>tt|��tt|��}|r(|t|�8}tdd�|D��}|S)Ncss(|] }|jd�s|jd�r|VqdS)�_�__N)rp�endswith)rAr�rcrcrd�	<genexpr>�	sz&detect_api_mismatch.<locals>.<genexpr>)r�rx)Zref_apiZ	other_apireZ
missing_itemsrcrcrdr<�	s
cCs�|dkr|jf}nt|t�r"|f}t|�}xbt|�D]V}|jd�s4||krLq4t||�}t|dd�|ks�t|d�r4t|tj	�r4|j
|�q4W|j|j|�dS)Nr�ra)
r`r�rtr�rxrpr�r��types�
ModuleType�addZassertCountEqual�__all__)Z	test_caser�Zname_of_moduleZextraZ	blacklistZexpectedrur�rcrcrdr=�	s)


c@s$eZdZdZdZdd�Zdd�ZdS)rZNc
Csrtjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
rlYnLXi|_
x�|j|j|jgD].}|j
||j�}|j||j�}||f|j
|<q�Wn�tdk	�r
y*tjtj�|_tjtjd|jdf�Wnttfk
�rYnXtjdk�rndddd	g}tj|tjtjd
�}|�|j�d}	WdQRX|	j�dk�rntdd
dd�|S)Nr�rr�rr�z/usr/bin/defaultsr]zcom.apple.CrashReporterZ
DialogType)r�r�s	developerz:this test triggers the Crash Reporter, that is intentionalr�T)�endr
) rnrorpr�r�r��_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�rm�	old_modes�CRT_WARN�	CRT_ERROR�
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPEZcommunicaterar�)
rfr�ZSEM_NOGPFAULTERRORBOXr��report_type�old_mode�old_file�cmd�procr�rcrcrdr�2
sN




zSuppressCrashReport.__enter__cGs�|jdkrdStjjd�rl|jj|j�|jr�ddl}xj|jj�D]$\}\}}|j	||�|j
||�qBWn6tdk	r�ytjtj
|j�Wnttfk
r�YnXdS)Nr�r)r�rnrorpr�r�r�r�r�r�r�r�r�r�r�r�)rfr�r�r�r�r�rcrcrdr�s
s
zSuppressCrashReport.__exit__)r`rarbr�r�r�r�rcrcrcrdrZ)
sAcsrt���d�y�j��Wn$ttfk
r@t��d��YnXd�����fdd�}|j|�t��|�dS)NFTcs �rt����n
t���dS)N)r�r[rc)�
attr_is_local�	attr_name�object_to_patchr�rcrd�cleanup�
szpatch.<locals>.cleanup)r�rjr�rZ
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rc)r�r�r�r�rd�patch�
s


r�cCsFyddl}Wntk
r YnX|j�r4tjd��ddl}|j|�S)NrzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)�tracemallocrmZ
is_tracingrrrsr��run_in_subinterp)r�r�r�rcrcrdr��
s
r�csHG��fdd�d|�}d�|||���|jtt��t�|j��dS)NcseZdZ��fdd�ZdS)z%check_free_after_iterating.<locals>.Acs*d�yt��Wntk
r$YnXdS)NT)�next�
StopIteration)rf)�done�itrcrd�__del__�
s
z-check_free_after_iterating.<locals>.A.__del__N)r`rarbr�rc)r�r�rcrd�A�
sr�F)rKr�r�r�Z
assertTrue)r�r�rCr�r�rc)r�r�rd�check_free_after_iterating�
s	r�cCs|ddlm}m}m}|j�}|j|�xP|jD]F}|r@||kr@q.t||�}|rPn
|dkrZq.|j|d�dkr.|dSq.WdS)Nr)�	ccompilerr��spawn)	Z	distutilsr�r�r�Znew_compilerZcustomize_compilerZexecutablesr�Zfind_executable)Z	cmd_namesr�r�r�Zcompilerrur�rcrcrdr^�
s	

cCs@d}tr6||kr6tdkr.tjddg�j�dkatr6|}tj|�S)Ng�h㈵��>Zgetpropzro.kernel.qemu�1)rA�_is_android_emulatorrZcheck_outputrarnrD)ZintervalZminimum_intervalrcrcrdrD�
sc
cs>tjj�}tj�}ztj�dVWd|r8tj|dd�XdS)NT)r�Zall_threads)rnr�rFrZ�
is_enabledr�r�)r@r�rcrcrd�disable_faulthandler�
s

r�c	/Cs�tjjd
�r8ytjd�}t|�dStk
r6YnXd}ttd�rjytjd�}Wnt	k
rhYnXd}tjdkr�yd	dl
}|jWntt
fk
r�Yn0Xi}x(|j|j|jfD]}|j|d	�||<q�Wzpd	}xft|�D]Z}ytj|�}Wn4t	k
�r(}z|jtjk�r�WYdd}~Xq�Xtj|�|d7}q�WWd|dk	�rzx*|j|j|jfD]}|j|||��q`WX|S)N�linux�freebsdz
/proc/self/fdr��sysconf�SC_OPEN_MAXrr)r�r�)rnrorpr�r�r�r�r�r�r�r�r�r�rmr�r�r�rO�dupr�ZEBADFr)	�namesZMAXFDr�r�r�rPr@Zfd2r�rcrcrdr_	sP





c@s$eZdZdd�Zdd�Zdd�ZdS)�SaveSignalscCsjddl}||_ttd|j��|_x>dD]6}yt||�}Wntk
rNw&YnX|jj|�q&Wi|_dS)Nrr�SIGKILL�SIGSTOP)r�r�)	�signalr{rO�NSIG�signalsr�r�ryrf)rfr�Zsigname�signumrcrcrdrgMs
zSaveSignals.__init__cCs4x.|jD]$}|jj|�}|dkr"q||j|<qWdS)N)r�r��	getsignalrf)rfr��handlerrcrcrd�saveZs
zSaveSignals.savecCs*x$|jj�D]\}}|jj||�qWdS)N)rfr�r�)rfr�r�rcrcrd�restorefszSaveSignals.restoreN)r`rarbrgr�r�rcrcrcrdr�Ds	
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�FakePathcCs
||_dS)N)r�)rfr�rcrcrdrgnszFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>)r�)rfrcrcrd�__repr__qszFakePath.__repr__cCs6t|jt�s$t|jt�r,t|jt�r,|j�n|jSdS)N)r�r��
BaseExceptionr�rx)rfrcrcrd�
__fspath__ts
zFakePath.__fspath__N)r`rarbrgr�r�rcrcrcrdr�ksr�ccs.tj�}ztj|�dVWdtj|�XdS)N)rn�get_int_max_str_digits�set_int_max_str_digits)Z
max_digitsZcurrentrcrcrd�adjust_int_max_str_digits|s


r�)T)F)F)N)Nii@i@i@ii)rrrrrrrrrr r!)r%r#r&r'r()NF)F)r5F)N)Fi@ii)T)N)Nr)rR)N(r`rm�collections.abc�collections�
contextlibZdatetimer�rZr?r�r�r�rl�importlib.utilr�Zlogging.handlersrer�r�rorur�rr�r�rrnr�r*r�r�rrZurllib.errorr_rfZ
testresultrrJrLZmultiprocessing.processr&�zlibrV�bz2Zlzmar�r�r�r�r	r
rrsr�contextmanagerrjr
r~r�r:r;rr6rrrrr0rr�rrrr�rpr�r�r�r�r�rr�rr�rr�r r!r�r"r#r$r%rErrr	rGrHrJrrFrrZ
SOCK_MAX_SIZEZ
skipUnlessr�
__getformat__r7r9r0r1r2r@r�rrArCrurr�r.ZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr2rr]r}r1r4rr�rKr�r�r�r�ZTEST_SUPPORT_DIRr9r�r[rrr[rGr&rI�objectrcr�rRr�r�rSr�abc�MutableMappingrTr�r'r�r�r(r�r)r*r+r�rrrr�r�r�r�r�r�r�r�r�r�r�rUr\r�r�rZ_4GrrrYr	r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSr�ZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZr�r�r�r^r�rDr�r_r�r�r�rcrcrcrd�<module>s�











2	
!

J			>%	


%2' 5M		


$
#
0







(




"
#
	"
:_";'

?>