Your IP : 3.138.134.106


Current Path : /opt/alt/python36/lib64/python3.6/test/support/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/support/__pycache__/__init__.cpython-36.opt-2.pyc

3

 f���@s�edkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl!Z!ddl"m#Z#yddl$Z$ddl%Z%Wnek
�r6dZ$dZ%YnXyddl&Z'Wnek
�r^dZ'YnXyddl(Z(Wnek
�r�dZ(YnXyddl)Z)Wnek
�r�dZ)YnXyddl*Z*Wnek
�r�dZ*YnXyddl+Z+Wnek
�r�dZ+YnXyddl,Z,Wnek
�r&dZ,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`g[Z-Gdad�de.�Z/Gdbd�de/�Z0Gdcd
�d
e/�Z1Gddd�dej2�Z3ej4�d\dfdg��Z5�d]fdi�djd�Z6dkdl�Z7dmdn�Z8dod;�Z9dpd<�Z:ffdhfdqd�Z;drd7�Z<dZ=dZ>da?da@dZAdhZBdaCdsd�ZDdtd�ZEdud�ZFdvdw�ZGejjHdx��r��d^dydz�ZId{d|�ZJd}d~�ZKdd��ZLd�d��ZMnejNZJejOZKd�d��ZLd�d��ZMd�d�ZNd�d��ZOd�d�ZPd�d��ZQd�d�ZRd�d��ZSd�d"�ZT�d_d�d#�ZUd�d��ZVd�d$�ZWd�d%�ZXd�d&�ZYd�ZZd�Z[ej\ej]fd�dH�Z^eZfd�dI�Z_d�dK�Z`d�d��Zaea�Zbd�d��Zc�dbZd�deZeejfegjhd��jHd��d��Ziejfe(d��Zjejfe)d��Zkejfe*d��Zlejfe+d��ZmejjHd��Znejod��Zpepdk	�o6epdkZqejd�k�rTeq�rNd�nd�ZrndZrejsd�k�rjd�Ztnd�Ztd�juetejv��ZtdZwxL�dfD]BZxyejyejzex��exk�r�e{�Wne{k
�r�YnXexZwP�q�Wetd�Z|ejd�k�r�ddl}Z}e}j~d�e|�Z|ej�Z�dZ�ejsd�k�rdej��jd�k�r�etd�Z�ye�j�e��Wne�k
�rLYnXe�d�e�e�f�dZ�nBejd�k�r�yd�j�e��Wn&e�k
�r�etd�j�e�dăZ�YnXdZ�xF�dgD]<Zsyesj�e��Wn&e�k
�r�ejzet�esZ�PYnX�q�Wew�retd�ewZ�ndZ�ej��Z�dhZ�ej4�dhd�d˄�Z�ej4�did�d̈́�Z�ej4�djd�d��Z�e�edЃ�rfej4d�dL��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�d҃Z��dkd�d�Z�d�d�Z�d�d\�Z�d�dׄZ�ddd؜d�d'�Z�d�dJ�Z�Gd�d܄d�e��Z��dld�dބZ�ej4d�dS��Z�ej4d�dT��Z�Gd�d�de��Z�Gd�dU�dUej�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�ej4d�fd�d�d,��Z�ej4d�d��Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�ej4d�d��Z�d�d�Z�d�Z�d�Z�e�ed���r�d�e�Z�d�Z�e�d�Z�d�d��Z�d�d��Z��dmZ��dnZ��d�d�Z��ddV�Z��dd]�ZdoZ�d�e�Z�d�e�Z�d�e�Z�ej�ZȐddZ�Z�G�d�d��d�Zʐdp�dd4�Zːd	d5�Z�G�d
d-�d-�Z͐d�d�Zΐd
�d�Zϐdd?�ZАdd6�Zѐdq�d�d�Z�daӐdd@�ZԐd�d�ZՐddC�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�ejo�d(�Z�e�j�dk	�
o�e�Z�ejfe�d)�Z�dr�d*d/�Z�d+�d,�Z�d-�d.�Z�dhZ�d/dO�Z�d0dP�Z�d1dQ�Z�ej4�ds�d3�d4��Z�d5dM�Z�ej4�dt�d6dR��Z�ej4�d7dX��Z�ej4�d8dW��Z�d9�d:�Z�ej�e�e�d;��d<�Z�d=�d>�Z��d?�d@�Z�G�dAdN�dNej�j��Z�G�dBdY�dYe��Z�da��dCd �Z��dDd0�Z�da��dE�dF�Z��dGd9��Z�dHd!��Zf�dI��dJd=��Zdfff�dKd>��ZG�dLd[�d[��Z�dM�dN��Z�dO�dP��Zff�dQ�dR��Zgf�dSd_��Zd�a	�dTdE��Z
ej4�dU�dV���Z�dWd`��ZG�dX�dY��dY��Z
G�dZ�d[��d[��ZdS(uz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�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__�rbrb�-/opt/alt/python36/lib64/python3.6/__init__.pyr	usc@seZdZdS)r
N)r_r`rarbrbrbrcr
xsc@seZdZdS)rN)r_r`rarbrbrbrcr{sc@seZdZdS)rN)r_r`rarbrbrbrcr~sTccs8|r.tj��tjddt�dVWdQRXndVdS)N�ignorez.+ (module|package))�warnings�catch_warnings�filterwarnings�DeprecationWarning)rdrbrbrc�_ignore_deprecated_imports�s
riF)�required_oncCsft|��Ty
tj|�Stk
rV}z&tjjt|��r8�tj	t
|���WYdd}~XnXWdQRXdS)N)ri�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedrj�msgrbrbrcr
�s	

cCs^|tjkrt|�tj|=x>ttj�D]0}||ks@|j|d�r&tj|||<tj|=q&WdS)N�.)rm�modules�
__import__�listro)rt�orig_modules�modnamerbrbrc�_save_and_remove_module�s
r}cCs>d}ytj|||<Wntk
r.d}YnXdtj|<|S)NTF)rmrx�KeyError)rtr{Zsavedrbrbrc�_save_and_block_module�s

rcCs|r
tjSdd�S)NcSs|S)Nrb)�frbrbrc�<lambda>�sz$anticipate_failure.<locals>.<lambda>)rqZexpectedFailure)Z	conditionrbrbrcr9�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_testsrbrbrcr:�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)
rir}r�appendrkr
rl�itemsrmrx)rtZfreshZblockedrur{Znames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removerbrbrcr�s$





cCs>yt||�}Wn&tk
r4tjd||f��YnX|SdS)Nzobject %r has no attribute %r)�getattr�AttributeErrorrqrr)�objrtZ	attributerbrbrcr5s
cCs|adS)N)�_original_stdout)�stdoutrbrbrcr)scCs
tptjS)N)r�rmr�rbrbrbrcr-scCs&ytj|=Wntk
r YnXdS)N)rmrxr~)rtrbrbrcr0s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�errrbrbrc�
_force_run6sr��wincCs�||�|r|}ntjj|�\}}|p(d}d}x<|dkrjtj|�}|rJ|n||ksVdStj|�|d9}q0Wtjd|tdd�dS)Nrwg����MbP?g�?r�z)tests may fail, delete still pending for �)�
stacklevel)	r�r��split�listdir�time�sleepre�warn�RuntimeWarning)r��pathname�waitallr�rt�timeout�Lrbrbrc�_waitforAs



r�cCsttj|�dS)N)r�r�r)�filenamerbrbrc�_unlinkbsr�cCsttj|�dS)N)r�r��rmdir)r�rbrbrc�_rmdiresr�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�rm�
__stderr__r��S_ISDIRr�r�r)r�rt�fullname�mode�exc)�
_rmtree_innerrbrcr�is

z_rmtree.<locals>._rmtree_innerT)r�cSst|tj|�S)N)r�r�r�)�prbrbrcr�xsz_rmtree.<locals>.<lambda>)r�)r�rb)r�rc�_rmtreehsr�c
Cs^yddl}Wntk
r Yn:X|jt|�d�}|jjj||t|��}|rZ|d|�S|S)Nrr�)�ctypesrlZcreate_unicode_buffer�len�windll�kernel32ZGetLongPathNameW)r�r��bufferZlengthrbrbrc�	_longpathzs
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�rtr�r�)r�rbrcr��s

z_rmtree.<locals>._rmtree_inner)�shutilrr�r�r�)r�rb)r�rcr��s
cCs|S)Nrb)r�rbrbrcr��scCs*yt|�Wnttfk
r$YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rbrbrcr�scCs&yt|�Wntk
r YnXdS)N)r�r�)r�rbrbrcr��sr�cCs&yt|�Wntk
r YnXdS)N)r�r�)r�rbrbrcr�scCsBtjj|�}tjjtjj|��}tjj||d�}tj||�|S)N�c)	rk�util�cache_from_sourcer�r�r��abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrbrbrc�make_legacy_pyc�s
r�cCs\t|�xNtjD]D}tjj||d�}t|d�x dD]}ttjj||d��q8WqWdS)Nz.pyr��rr�)�optimization)r�rr�)	rrmr�r�r�rrkr�r�)r|r�r��optrbrbrcr�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_r`ra�wintypesZBOOL�DWORD�_fields_rb)r�rbrc�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_r`rar�rb)r�rbrc�ProcessSerialNumbersr�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rmrnror�Zctypes.wintypesr�r�Zuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr�Zwithdraw�updateZdestroy�	Exceptionrsr��format�typer_�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrb)r�r�rcr��sh

r�cCstdkp|tkS)N)r)�resourcerbrbrcr scCs>t|�s |dkrd|}t|��|dkr:t�r:ttj��dS)Nz"Use of the %r resource not enabled�gui)r rr�r�)r�rvrbrbrcr!%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�-rrrwz(%s version %s or higher required, not %s)rn�system�releaser�rp�map�int�
ValueErrorr�rsrqrr)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamerbrc�wrapper6sz:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�rc�	decorator5sz)_requires_unix_version.<locals>.decoratorrb)r�r�r�rb)r�r�rc�_requires_unix_version.sr�cGs
td|�S)NZFreeBSD)r�)r�rbrbrcr"IscGs
td|�S)NZLinux)r�)r�rbrbrcr#Rscs�fdd�}|S)Ncs"tj����fdd��}�|_|S)Ncsxtjdkrntj�d}yttt|jd���}Wntk
rBYn,X|�krndjtt	���}t
jd||f���||�S)Nr�rrwz&Mac OS X %s or higher required, not %s)rmrnZmac_verrpr�r�r�r�r�rsrqrr)r�r�r�r�r�)r�r�rbrcr�cs
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rcr�bsz#requires_mac_ver.<locals>.decoratorrb)r�r�rb)r�rcr$[sz	127.0.0.1z::1cCs"tj||�}t|�}|j�~|S)N)�socketrG�close)�familyZsocktypeZtempsock�portrbrbrcrF}s
8cCs�|jtjkr�|jtjkr�ttd�r>|jtjtj�dkr>t	d��ttd�r�dt
jkr�y |jtjtj�dkrpt	d��Wnt
k
r�YnXttd�r�|jtjtjd�|j|df�|j�d}|S)	N�SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTZWITHIN_PYTHON_RPM_BUILDzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)r�r��AF_INETr��SOCK_STREAMr�Z
getsockoptZ
SOL_SOCKETr�r
r��environr�r�Z
setsockoptr�bindZgetsockname)�sock�hostr�rbrbrcrG�s 



cCs:y|j|�Wn&tk
r4|j�tjd��YnXdS)Nzcannot bind AF_UNIX sockets)r�PermissionErrorr�rqrr)rZaddrrbrbrcrI�s
cCsZtjrVd}z<y"tjtjtj�}|jtdf�dStk
rBYnXWd|rT|j�XdS)NrTF)r�Zhas_ipv6ZAF_INET6rr�HOSTv6r�r�)rrbrbrc�_is_ipv6_enabled�s

r	cstj���fdd��}|S)NcsNy�||�Wn:tk
rH}zdt|�kr6tjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrsrqrr)r��kwargsr�)r�rbrc�dec�s
z&system_must_validate_cert.<locals>.dec)r�r�)r�rrb)r�rc�system_must_validate_cert�s	r
r�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�rer�r��getpidr)r��quietZdir_created�pidrbrbrc�temp_dir�s&


r,ccsftj�}ytj|�Wn.tk
rD|s,�tjd|tdd�YnXztj�VWdtj|�XdS)Nz)tests may fail, unable to change CWD to: r$)r�)r��getcwd�chdirr�rer�r�)r�r*Z	saved_dirrbrbrc�
change_cwd�s

r/�tempcwdccs:t||d��$}t||d��}|VWdQRXWdQRXdS)N)r�r*)r*)r,r/)rtr*Z	temp_pathZcwd_dirrbrbrcr�s�umaskccs&tj|�}z
dVWdtj|�XdS)N)r�r1)r1ZoldmaskrbrbrcrJs

�datacCsbtjj|�r|S|dk	r&tjj||�}tgtj}x*|D]"}tjj||�}tjj|�r8|Sq8W|S)N)r�r��isabsr��
TEST_HOME_DIRrm�exists)r�Zsubdirr�Zdn�fnrbrbrcr#s
cCs(tj|tjtjBtjB�}tj|�dS)N)r��open�O_WRONLY�O_CREAT�O_TRUNCr�)r��fdrbrbrcr5scCs,t|j��}dd�|D�}dj|�}d|S)NcSsg|]}d|�qS)z%r: %rrb)�.0Zpairrbrbrc�
<listcomp>=szsortdict.<locals>.<listcomp>z, z{%s})�sortedr�r�)�dictr�Z	reprpairsZ
withcommasrbrbrcrZ:s
cCs*ttd�}z|j�S|j�tt�XdS)N�wb)r7r�filenor�r)r�rbrbrc�make_bad_fdAs

rB)�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	exceptionZassertIsNotNonerC�assertEqualrD)�testcaseZ	statementrCrD�cmr�rbrbrcr%Ms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)r7�seekr�)r6r�)r�rLr�rbrc�check_valid_fileas
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...)r��Accept-Encoding�gzip�)r�zContent-Encoding)Zfileobjr@zinvalid resource %r���)rPrQ)Zurllib.requestZurllib.parse�pop�parseZurlparser�r�r�r��
TEST_DATA_DIRr5rr!rr�rZrequestZbuild_openerrQZ
addheadersr�r7Zheaders�getZGzipFile�read�writer�r
)Zurlr�r��urllibr�r6rOr��opener�out�srb)r�rLr�rcrHXs<	



c@s0eZdZdd�Zdd�Zedd��Zdd�Zd	S)
�WarningsRecordercCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrbrbrc�__init__�szWarningsRecorder.__init__cCsDt|j�|jkr t|jd|�S|tjjkr0dStd||f��dS)Nrz%r has no attribute %rrS)r�r_r`r�re�WarningMessage�_WARNING_DETAILSr�)ra�attrrbrbrc�__getattr__�s
zWarningsRecorder.__getattr__cCs|j|jd�S)N)r_r`)rarbrbrcre�szWarningsRecorder.warningscCst|j�|_dS)N)r�r_r`)rarbrbrc�reset�szWarningsRecorder.resetN)r_r`rarbrf�propertyrergrbrbrbrcr^�sr^c
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)�recordre�alwaysFzunhandled warning %srz)filter (%r, %s) did not catch any warning)rm�	_getframe�	f_globalsrW�clearrerfrx�simplefilterr^rz�message�re�matchrs�I�
issubclassr��remover�r_�AssertionError)�filtersr*�frame�registry�wZreraise�missingrv�cat�seenZwarningrbrbrc�_filterwarnings�s0
r}cOs.|jd�}|s$dtff}|dkr$d}t||�S)Nr*r�T)rW�Warningr})rvrr*rbrbrcrQ�s

ccsBtjdd�� }tjdtd�dVt�WdQRX|j|g�dS)NT)rirj)�category)rerfrg�ResourceWarning�
gc_collectrI)rJZwarnsrbrbrcrR�s
c@s$eZdZdd�Zdd�Zdd�ZdS)rcGsNtjj�|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rmrx�copy�original_modulesr_)raZmodule_namesZmodule_namer�rbrbrcrbs




zCleanImport.__init__cCs|S)Nrb)rarbrbrc�	__enter__szCleanImport.__enter__cGstjj|j�dS)N)rmrxr�r�)ra�
ignore_excrbrbrc�__exit__szCleanImport.__exit__N)r_r`rarbr�r�rbrbrbrcr�s
c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rScCstj|_i|_dS)N)r�r�_environ�_changed)rarbrbrcrbszEnvironmentVarGuard.__init__cCs
|j|S)N)r�)ra�envvarrbrbrc�__getitem__szEnvironmentVarGuard.__getitem__cCs*||jkr|jj|�|j|<||j|<dS)N)r�r�rW)rar��valuerbrbrc�__setitem__!s
zEnvironmentVarGuard.__setitem__cCs2||jkr|jj|�|j|<||jkr.|j|=dS)N)r�r�rW)rar�rbrbrc�__delitem__'s

zEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rarbrbrcr�.szEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rarbrbrc�__iter__1szEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rarbrbrc�__len__4szEnvironmentVarGuard.__len__cCs|||<dS)Nrb)rar�r�rbrbrc�set7szEnvironmentVarGuard.setcCs
||=dS)Nrb)rar�rbrbrc�unset:szEnvironmentVarGuard.unsetcCs|S)Nrb)rarbrbrcr�=szEnvironmentVarGuard.__enter__cGsJx<|jj�D].\}}|dkr0||jkr:|j|=q||j|<qW|jt_dS)N)r�r�r�r�r)rar��k�vrbrbrcr�@s

zEnvironmentVarGuard.__exit__N)r_r`rarbr�r�r�r�r�r�r�r�r�r�rbrbrbrcrSsc@s$eZdZdd�Zdd�Zdd�ZdS)�
DirsOnSysPathcGs(tjdd�|_tj|_tjj|�dS)N)rmr��original_value�original_object�extend)ra�pathsrbrbrcrbVszDirsOnSysPath.__init__cCs|S)Nrb)rarbrbrcr�[szDirsOnSysPath.__enter__cGs|jt_|jtjdd�<dS)N)r�rmr�r�)rar�rbrbrcr�^szDirsOnSysPath.__exit__N)r_r`rarbr�r�rbrbrbrcr�Jsr�c@s&eZdZdd�Zdd�Zddd�ZdS)	r&cKs||_||_dS)N)r��attrs)rar�rrbrbrcrbhszTransientResource.__init__cCs|S)Nrb)rarbrbrcr�lszTransientResource.__enter__NcCsT|dk	rPt|j|�rPx:|jj�D]$\}}t||�s4Pt||�|kr Pq Wtd��dS)Nz%an optional resource is not available)rsr�r�r�r�r�r)raZtype_r��	tracebackreZ
attr_valuerbrbrcr�os
zTransientResource.__exit__)NNN)r_r`rarbr�r�rbrbrbrcr&cs)�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||��qSrb)r�r�)r<rt�numrbrbrcr=�sz&transient_internet.<locals>.<listcomp>cSsg|]\}}tt||��qSrb)r�r�)r<rtr�rbrbrcr=�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��
isinstancer�r�ZgaierrorrZ�errorZ	HTTPError�codeZURLErrorr�rrm�stderrrYr�)r��n)�captured_errnos�denied�
gai_errnosrbrc�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r�ZgetdefaulttimeoutZsetdefaulttimeout�nntplibZNNTPTemporaryErrorrrmr�rYr�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��arb)r�r�r�rcr*�sP



c
csFddl}tt|�}tt||j��ztt|�VWdtt||�XdS)Nr)�ior�rm�setattr�StringIO)Zstream_namer�Zorig_stdoutrbrbrc�captured_output�s
r�cCstd�S)Nr�)r�rbrbrbrcr�scCstd�S)Nr�)r�rbrbrbrcr�scCstd�S)N�stdin)r�rbrbrbrcr�s
cCs*tj�trtjd�tj�tj�dS)Ng�������?)�gcZcollectr?r�r�rbrbrbrcr��s


r�c
cs.tj�}tj�z
dVWd|r(tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrbrbrc�
disable_gc
s
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�ro)ZcflagsZ	final_optr�rbrbrc�python_is_optimizeds
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrbrbrc�calcobjsize)sr�cCstjt|t�S)N)r�r��_vheaderr�)r�rbrbrc�calcvobjsize,sr���	cCspddl}tj|�}t|�tkr(|jt@sBt|�tkrLt|�jt@rL||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapirm�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrI)�test�o�sizer�r�rvrbrbrc�check_sizeof3s

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�rZorig_locale�loc)�catstrr��localesrbrc�innerDs$



z1run_with_locale.<locals>.decorator.<locals>.inner)r_�__doc__)r�r�)r�r�)r�rcr�Csz"run_with_locale.<locals>.decoratorrb)r�r�r�rb)r�r�rcrTBscs�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�rqrrr�r)r�r�r�Zorig_tz)r��tzrbrcr�hs





z-run_with_tz.<locals>.decorator.<locals>.inner)r_r�)r�r�)r�)r�rcr�gszrun_with_tz.<locals>.decoratorrb)r�r�rb)r�rcr[fs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�_1Grprq�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr�ZmemlimitrbrbrcrX�s$c@s$eZdZdd�Zdd�Zdd�ZdS)�_MemoryWatchdogcCsdjtj�d�|_d|_dS)Nz/proc/{pid}/statm)r+F)r�r�r)�procfile�started)rarbrbrcrb�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)r7rr�rer�r�r�rmr��flushr�
subprocess�Popen�
executableZDEVNULL�mem_watchdogr�r)rar�r�Zwatchdog_scriptrbrbrc�start�s
z_MemoryWatchdog.startcCs|jr|jj�|jj�dS)N)rr
Z	terminate�wait)rarbrbrc�stop�s
z_MemoryWatchdog.stopN)r_r`rarbrr
rbrbrbrcr�srcs���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��memuser�rqrrrr�r�rrr
)rar�r�maxsizeZwatchdog)�dry_runr�r�rbrcr��s*


z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)r�)rrr�)r�r�rcr��szbigmemtest.<locals>.decoratorrb)r�rrr�rb)rrr�rcr2�s
!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@)rr�rqrr)ra)r�rbrcr��sz!bigaddrspacetest.<locals>.wrapperrb)r�r�rb)r�rcr3�sc@seZdZdd�ZdS)r+cCstj�}||�|S)N)rqZ
TestResult)rar�r�rbrbrc�runszBasicTestRunner.runN)r_r`rarrbrbrbrcr+scCs|S)Nrb)r�rbrbrc�_idsrcCs<|dkrt�rtjtj�St|�r(tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�rq�skipr�r rr�)r�rbrbrc�requires_resources
rcCs&trt|krtjd|tf�StSdS)Nz%s at Android API level %d)r@�_ANDROID_API_LEVELrqrr)�levelr�rbrbrcr=scCstdd�|�S)NT)�cpython)�impl_detail)r�rbrbrcr4scKsVtf|�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 )	rAr�
_parse_guardsr>r�r�r�rqr)rv�guardsZ
guardnames�defaultrbrbrcr#s
rcCsTtdkr:ddl}y|j�daWntk
r8daYnXd}trF|Stj|�|�S)NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessingZQueuerlrqr)r�rrvrbrbrcr>1s
cCs*|sddidfSt|j��d}||fS)NrTFr)rz�values)rZis_truerbrbrcr@srcKs t|�\}}|jtj�j�|�S)N)rrWrnZpython_implementationr�)rrrbrbrcrAJscs,ttd�s�Stj���fdd��}|SdS)N�gettracecs.tj�}ztjd��||�Stj|�XdS)N)rmr!�settrace)r�rZoriginal_trace)r�rbrcr�Zs


zno_tracing.<locals>.wrapper)r�rmr�r�)r�r�rb)r�rc�
no_tracingUs
r#cCstt|��S)N)r#r4)r�rbrbrc�
refcount_testesr$cCsRg}xB|jD]8}t|tj�r2t||�|j|�q||�r|j|�qW||_dS)N)Z_testsr�rq�	TestSuite�
_filter_suiter�)�suiteZpredZnewtestsr�rbrbrcr&ps
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)rrmr�r�junit_xml_listrr�Zget_xml_elementZtestsRunrZ
wasSuccessfulr��errorsZfailuresr
)r'Zrunnerr�r�rbrbrc�
_run_suite|s"
r+cCstdkrdSt|j��SdS)NT)�_match_test_func�id)r�rbrbrc�
match_test�sr.cCsd|kotjd|�S)Nrwz[?*\[\]])rp�search)r�rbrbrc�_is_full_match_test�sr0csr|tkrdS|sd}f}nHttt|��r4t|�j}n.djttj|��}t	j
|�j��fdd�}|}t|�a|a
dS)N�|cs$�|�rdStt�|jd���SdS)NTrw)�anyr�r�)Ztest_id)�regex_matchrbrc�match_test_regex�sz)set_match_tests.<locals>.match_test_regex)�_match_test_patterns�allr�r0r��__contains__r��fnmatch�	translaterprHrqrpr,)Zpatternsr�Zregexr4rb)r3rc�set_match_tests�sr:cGs�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)rqr%ZTestCaser�rsrmrxZaddTestZ
findTestCasesr�Z	makeSuiter&r.r+)�classesZvalid_typesr'�clsrbrbrcr,�s





cCsdS)Nrbrbrbrbrc�_check_docstrings�sr=�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(r?r@r�r�rbrbrcr-�scCstjj�fS)N)rmrxr�rbrbrbrc�
modules_setupsrAcCs:dd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs"g|]\}}|jd�r||f�qS)z
encodings.)ro)r<r�r�rbrbrcr=sz#modules_cleanup.<locals>.<listcomp>)rmrxr�rmr�)Z
oldmodules�	encodingsrbrbrc�modules_cleanups
rCcCs"trtj�tjj�fSdffSdS)Nr)�_thread�_count�	threading�	_danglingr�rbrbrbrcrM<scGsJtsdSd}x8t|�D],}tj�tjf}||kr2Ptjd�t�qWdS)N�dg{�G�z�?)rD�rangerErFrGr�r�r�)Zoriginal_valuesZ
_MAX_COUNT�countr rbrbrcrNBs
cs"ts�Stj���fdd��}|S)Ncst�}z�|�St|�XdS)N)rMrN)r��key)r�rbrcr�Vszreap_threads.<locals>.decorator)rDr�r�)r�r�rb)r�rcrONs�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�?)rDrEr�Z	monotonicrur�r�)r�Z	old_countZ
start_timeZdeadlinerJZdtrvrbrbrc�wait_threads_exit`s
$
rNc
CsZttd�rVd}xFy2tj|tj�\}}|dkr.Ptd|tjd�WqPYqXqWdS)N�waitpidrrz2Warning -- reap_children() reaped child process %s)r�rS)r�r�rO�WNOHANGr�rmr�)Zany_processr+�statusrbrbrcrK�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|�qSrb)�isAlive)r<r�rbrbrcr=�sz!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSsg|]}|j�r|�qSrb)rS)r<r�rbrbrcr=�szUnable to join %d threads)rzrr�rr�r�r�rIr��max�faulthandlerZdump_tracebackrmr�ru)ZthreadsZunlockrr�ZendtimeZ	starttimer�rbrbrcrP�s>

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




ccsX||kr0||}|||<z
|VWd|||<Xn$|||<z
dVWd||krR||=XdS)Nrb)r��itemrWrXrbrbrcrU�s

cCstjdd|�j�}|S)Ns\[\d+ refs, \d+ blocks\]\r?\n?�)rp�sub�strip)r�rbrbrc�strip_python_stderr�sr]Z	getcountsz-types are immortal if COUNT_ALLOCS is definedcCstj�S)N)rZ_args_from_interpreter_flagsrbrbrbrc�args_from_interpreter_flags	sr^cCstj�S)N)rZ"_optim_args_from_interpreter_flagsrbrbrbrc�!optim_args_from_interpreter_flags	sr_c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rLcCstjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerrb�matcher)rarcrbrbrcrb	szTestHandler.__init__cCsdS)NFrb)rarbrbrc�shouldFlush	szTestHandler.shouldFlushcCs|j|�|jj|j�dS)N)r�r�r��__dict__)rarirbrbrc�emit"	s
zTestHandler.emitcKs.d}x$|jD]}|jj|f|�rd}PqW|S)NFT)r�rc�matches)rarr��drbrbrcrg&	szTestHandler.matchesN)r_r`rarbrdrfrgrbrbrbrcrL	s	c@s eZdZdZdd�Zdd�ZdS)	rWrvrocKs<d}x2|D]*}||}|j|�}|j|||�s
d}Pq
W|S)NTF)rW�match_value)rarhrr�r�r��dvrbrbrcrg5	s

zMatcher.matchescCsHt|�t|�krd}n.t|�tk	s,||jkr6||k}n|j|�dk}|S)NFr)r�rs�_partial_matches�find)rar�rjr�r�rbrbrcriF	s
zMatcher.match_valueN)rvro)r_r`rarkrgrirbrbrbrcrW1	sc
CsZtdk	rtStd}ytjt|�d}Wntttfk
rFd}YnXtj|�|a|S)NrTF)�_can_symlinkrr��symlinkr��NotImplementedErrorr�rt)Zsymlink_path�canrbrbrcrT	s

cCs t�}d}|r|Stj|�|�S)Nz*Requires functional symlink implementation)rrqr)r��okrvrbrbrcr.c	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)�dirr@s	user.testrZstrusted.foos42z
2.6.(\d{1,2})r�')�
_can_xattrr�r�r%r&Zmkstempr7rrrrArnr�rprqr�r�r�rr�)rpZtmp_dirZtmp_fpZtmp_name�fpZkernel_versionr�rbrbrc�	can_xattrj	s,

rwcCs t�}d}|r|Stj|�|�S)Nz(no non-broken extended attribute support)rwrqr)r�rqrvrbrbrcr7�	scCs^tj|d��H}|j}|j�}||kr,|j�}ytjj||�Stk
rNdSXWdQRXdS)N)rsF)	r%ZNamedTemporaryFilert�upperr�r�r��samefiler�)Z	directory�base�	base_pathZ	case_pathrbrbrcr�	s)rdcCs>tt|��tt|��}|r(|t|�8}tdd�|D��}|S)Ncss(|] }|jd�s|jd�r|VqdS)�_�__N)ro�endswith)r<r�rbrbrc�	<genexpr>�	sz&detect_api_mismatch.<locals>.<genexpr>)r�rs)Zref_apiZ	other_apirdZ
missing_itemsrbrbrcr;�	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|r`)
r_r�rsr�rsror�r��types�
ModuleType�addZassertCountEqual�__all__)Z	test_caser�Zname_of_moduleZextraZ	blacklistZexpectedrtr�rbrbrcr<�	s)


c@s$eZdZdZdZdd�Zdd�ZdS)rYNc
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/defaultsrXzcom.apple.CrashReporterZ
DialogType)r�r�s	developerz:this test triggers the Crash Reporter, that is intentionalr�T)�endr) rmrnror�r�r��_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�rl�	old_modes�CRT_WARN�	CRT_ERROR�
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPEZcommunicater\r�)
rar�ZSEM_NOGPFAULTERRORBOXr��report_type�old_mode�old_file�cmd�procr�rbrbrcr��	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�rmrnror�r�r�r�r�r�r�r�r�r�r�r�)rar�r�r�r�r�rbrbrcr�0
s
zSuppressCrashReport.__exit__)r_r`rar�r�r�r�rbrbrbrcrY�	sAcsrt���d�y�j��Wn$ttfk
r@t��d��YnXd�����fdd�}|j|�t��|�dS)NFTcs �rt����n
t���dS)N)r�rVrb)�
attr_is_local�	attr_name�object_to_patchr�rbrc�cleanup[
szpatch.<locals>.cleanup)r�rer�r~Z
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rb)r�r�r�r�rc�patchE
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)�tracemallocrlZ
is_tracingrqrrr��run_in_subinterp)r�r�r�rbrbrcr�g
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)ra)�done�itrbrc�__del__}
s
z-check_free_after_iterating.<locals>.A.__del__N)r_r`rar�rb)r�r�rbrc�A|
sr�F)rFr�r�r�Z
assertTrue)r�r�r<r�r�rb)r�r�rc�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�Zcompilerrtr�rbrbrcr]�
s	

cCs@d}tr6||kr6tdkr.tjddg�j�dkatr6|}tj|�S)Ng�h㈵��>Zgetpropzro.kernel.qemu�1)r@�_is_android_emulatorrZcheck_outputr\rmrC)�intervalZminimum_intervalrbrbrcrC�
sc
cs>tjj�}tj�}ztj�dVWd|r8tj|dd�XdS)NT)r�Zall_threads)rmr�rArU�
is_enabledr�r�)r;r�rbrbrc�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�)rmrnror�r�r�r�r�r�r�r�r�r�rlr�r�r�rI�dupr�ZEBADFr�)	�namesZMAXFDr�r�r�rJr;Zfd2r�rbrbrcr^�
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�)	�signalrzrI�NSIG�signalsr�r�rtra)rar�Zsigname�signumrbrbrcrb
s
zSaveSignals.__init__cCs4x.|jD]$}|jj|�}|dkr"q||j|<qWdS)N)r�r��	getsignalra)rar��handlerrbrbrc�saves
zSaveSignals.savecCs*x$|jj�D]\}}|jj||�qWdS)N)rar�r�)rar�r�rbrbrc�restore#szSaveSignals.restoreN)r_r`rarbr�r�rbrbrbrcr�s	
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�FakePathcCs
||_dS)N)r�)rar�rbrbrcrb+szFakePath.__init__cCsd|j�d�S)Nz
<FakePath �>)r�)rarbrbrc�__repr__.szFakePath.__repr__cCs6t|jt�s$t|jt�r,t|jt�r,|j�n|jSdS)N)r�r��
BaseExceptionr�rs)rarbrbrc�
__fspath__1s
zFakePath.__fspath__N)r_r`rarbr�r�rbrbrbrcr�(sr�)T)F)F)Nii@i@i@ii)rrrrrrrrrrr)r rr!r"r#)NF)F)r0F)N)Fi@ii)T)N)Nr)rL)N(r_rl�collections.abc�collections�
contextlibZdatetimer�rUr8r�r�rk�importlib.utilr�Zlogging.handlersr`r�r�rnrpr�r�r�r�rrmr�r%r�r�rqZurllib.errorrZreZ
testresultrrDrFZmultiprocessing.processr�zlibrQ�bz2Zlzmar�r�r�r	r
rrrr�contextmanagerrir
r}rr9r:rr5rrrr�r)rr�rrrr�ror�r�r�r�r�rr�rr�rr�r r!r�r"r#r$rDrrrrFrGrIr	rEr
rZ
SOCK_MAX_SIZEZ
skipUnlessr��
__getformat__r6r8r/r0r1r?r�rr@rBrtrr�r)ZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr-rr\r,r/rr�rJr�r�r�r�ZTEST_SUPPORT_DIRr4r�rVrrrZrBr%rH�objectr^r}rQrRr�abc�MutableMappingrSr�r&r�r�r'r�r(r)r*r�rrrr�r�r�r�r�r�r�r�r�r�r�rTr[r�r�rZ_4Grr�rXrr2r3r+rrr=r4rrr>rrAr#r$r&r+r,r5r.r0r:r,r=ZMISSING_C_DOCSTRINGSr�ZHAVE_DOCSTRINGSZrequires_docstringsr-rArCZenvironment_alteredrMrNrOrNrKrPrVrUr]ZskipIfZrequires_type_collectingr^r_rarbrLrWrmrr.rurwr7rr;r<rYr�r�r�r]r�rCr�r^r�r�rbrbrbrc�<module>s�










2	
!

J			>&	


%2' 5M		


$
#
0







(




"
#
	"


:_";'

?>