Your IP : 18.218.63.176


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



$�Yf
Q��@s�edkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZ
ddlZ
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZddl Z Wnek
r�dZdZ YnXyddl!Z"Wnek
r�dZ"YnXyddl#Z#Wnek
r�dZ#YnXyddl$Z$Wnek
r
dZ$YnXyddl%Z%Wnek
r8dZ%YnXyddl&Z&Wnek
rcdZ&YnXyddl'Z'Wnek
r�dZ'YnXdddddd	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@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTgQZ(GdUd	�d	e)�Z*GdVd
�d
e*�Z+GdWd�dej,�Z-ej.dXdYdZ��Z/d[d\fd]d�Z0d^d_�Z1d`da�Z2dbd8�Z3dcd9�Z4ffd[ddd
�Z5ded4�Z6dfZ7dZ8da9da:d[Z;da<da=dgd�Z>dhd�Z?did�Z@djdk�ZAejjBdl�r�d[dmdn�ZCdodp�ZDdqdr�ZEdsdt�ZFnejGZDejHZEdudt�ZFdvd�ZGdwdx�ZHdyd�ZIdzd{�ZJd|d�ZKd}d~�ZLdd�ZMdd�d �ZNd�d��ZOd�d!�ZPd�d"�ZQd�d#�ZRd�ZSd�ZTejUejVd�d@�ZWeSd�dA�ZXd�d��ZYeY�ZZd�d��Z[d:Z\d=Z]ej^e_j`d��jBd��d��Zaej^e#d��Zbej^e$d��Zcej^e%d��Zdej^e&d��ZeejjBd��Zfejgd�kr�d�Zhnd�Zhd�jiehejj��ZhdZkxDd>D]<Zlyejmejnel��Wneok
r�Yq�XelZkPq�Wehd�Zpejd�kr6ddlqZqeqjrd�ep�Zpejs�ZtdZuejgd?kr�ejv�jd�krehd�Zuyeujwet�Wnexk
r�YqXeyd�euetf�dZunKejd�kryd�jzet�Wn(e{k
rehd�jzetd��ZuYnXdZ|xHd@D]@Zgyegjzet�Wqe{k
rPejneh�egZ|PYqXqWekrlehd�ekZ}ndZ}ej~�Zej.dd[d�d���Z�ej.d[d�d���Z�ej.d�d[d�d��Z�e�ed��r�ej.d�dC��Z�ej�j�ej�j�e���Z�ej�j�e��Z�ej�j�e�d��Z�dd�d�Z�d�d�Z�d�dS�Z�d�d��Z�d�dd�dd�d$�Z�d�dB�Z�Gd�d��d�e��Z�d[d�d��Z�ej.d�dJ��Z�ej.d�dK��Z�Gd�d�de��Z�Gd�dL�dLej�j��Z�Gd�d��d�e��Z�Gd�d%�d%e��Z�e�e�d�ej��Z�e�e�d�ej��Z�e�e�d�ej��Z�ej.d�d�d�fd�d)��Z�ej.d�d���Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�ej.d�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�dAZ�dBZ�d�d��Z�d�dM�Z�d�dT�Z�dCZ�d�e�Z�d�e�Z�d�e�Z�ej�Z�d�dQ�Z�Gd�d��d��Z�dXd�d1�Z�d�d2�Z�Gd�d*�d*�Z�d�d��Z�d�d��Z�d�d3�Z�dd�d�Z�da�dd;�Z�dd�Z�dd=�Z�dd�Z�dd�Z�d	d
�Z�dd�Z�d
d�Z�dd+�Z�dd�Z�e��o�ejdko�ej�d�Z�e�j�dk	o�e�Z�ej^e�d�Z�dddd,�Z�dd�Z�dd�Z�ddF�Z�ddG�Z�ddH�Z�ddD�Z�ej.dddI��Z�ej.ddO��Z�ej.d dN��Z�d!d"�Z�ej�e�ed#�d$�Z�d%d&�Z�Gd'dE�dEe
j�j��Z�Gd(dP�dPe��Z�da�d)d�Z�d*d-�Z�da�d+d,�Z�d-d6�Z�d.d�Z�d/fd0d:�Z�Gd1dR�dR�Z�d2d3�Z�d4d5�Z�fd6d7�Z�dS(Dztest.supportz.support must be imported from the test package�N�
PIPE_MAX_SIZE�verbose�
max_memuse�
use_resources�failfast�Error�
TestFailed�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�requires_multiprocessing_queue�	is_jython�check_impl_detail�HOST�IPV6_ENABLED�find_unused_port�	bind_port�open_urlresource�
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_tzc@seZdZdS)rN)�__name__�
__module__�__qualname__�rVrV�-/opt/alt/python35/lib64/python3.5/__init__.pyrnsc@seZdZdS)rN)rSrTrUrVrVrVrWrqsc@seZdZdS)r	N)rSrTrUrVrVrVrWr	tsTccs>|r5tj��tjddt�dVWdQRXndVdS)N�ignorez.+ (module|package))�warnings�catch_warnings�filterwarnings�DeprecationWarning)rXrVrVrW�_ignore_deprecated_imports|s
r]F�required_oncCs�t|��nytj|�SWnUtk
ru}z5tjjt|��rN�tj	t
|���WYdd}~XnXWdQRXdS)N)r]�	importlibr
�ImportError�sys�platform�
startswith�tuple�unittest�SkipTest�str)�name�
deprecatedr^�msgrVrVrWr
�s	
cCs{|tjkr#t|�tj|=xQttj�D]@}||ksX|j|d�r3tj|||<tj|=q3WdS)N�.)ra�modules�
__import__�listrc)rh�orig_modules�modnamerVrVrW�_save_and_remove_module�s

rqcCsGd}ytj|||<Wntk
r5d}YnXdtj|<|S)NTF)rarl�KeyError)rhroZsavedrVrVrW�_save_and_block_module�s

rscCs|r
tjSdd�S)NcSs|S)NrV)�frVrVrW�<lambda>�sz$anticipate_failure.<locals>.<lambda>)reZexpectedFailure)Z	conditionrVrVrWr6�scCsk|dkrd}tjjtjjtjjt���}|jd|d|d|�}|j|�|S)Nztest*Z	start_dirZ
top_level_dir�pattern)�os�path�dirname�__file__ZdiscoverZaddTests)Zpkg_dir�loaderZstandard_testsrvZtop_dirZ
package_testsrVrVrWr7�s			
cCs�t|���i}g}t||�z}y^x|D]}t||�q3Wx*|D]"}t||�sQ|j|�qQWtj|�}Wntk
r�d}YnXWdx'|j�D]\}	}
|
tj	|	<q�Wx|D]}tj	|=q�WX|SWdQRXdS)N)
r]rqrs�appendr_r
r`�itemsrarl)rhZfreshZblockedriroZnames_to_removeZ
fresh_nameZblocked_nameZfresh_moduleZ	orig_name�moduleZname_to_removerVrVrWr�s$





cCsIyt||�}Wn+tk
r@tjd||f��YnX|SdS)Nzobject %r has no attribute %r)�getattr�AttributeErrorrerf)�objrhZ	attributerVrVrWr2
s

�cCs
|adS)N)�_original_stdout)�stdoutrVrVrWrscCs
tptjS)N)r�rar�rVrVrVrWr#scCs'ytj|=Wntk
r"YnXdS)N)rarlrr)rhrVrVrWr
&s
cGs�y||�SWntk
r�}z_tdkr`td|jj|f�td|j|f�tj|tj�||�SWYdd}~XnXdS)N�z%s: %szre-run %s%r)	�OSErrorr�print�	__class__rSrw�chmod�stat�S_IRWXU)rx�func�args�errrVrVrW�
_force_run,sr��wincCs�||�|r|}n$tjj|�\}}|p:d}d}xR|dkr�tj|�}|rm|n	||ks}dStj|�|d9}qFWtjd|tdd�dS)Nrkg����MbP?g�?r�z)tests may fail, delete still pending for �
stacklevel�)	rwrx�split�listdir�time�sleeprY�warn�RuntimeWarning)r��pathname�waitallryrh�timeout�LrVrVrW�_waitfor7s
	

r�cCsttj|�dS)N)r�rwr)�filenamerVrVrW�_unlinkXsr�cCsttj|�dS)N)r�rw�rmdir)ryrVrVrW�_rmdir[sr�cs<�fdd��t�|dd�tdd�|�dS)Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}WnHtk
r�}z(td||fdt	j
�d}WYdd}~XnXtj|�r�t
�|dd�t|tj|�qt|tj|�qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s�filerr�T)r�rwr�rx�join�lstat�st_moder�r�ra�
__stderr__r��S_ISDIRr�r�r)rxrh�fullname�mode�exc)�
_rmtree_innerrVrWr�_s
z_rmtree.<locals>._rmtree_innerr�TcSst|tj|�S)N)r�rwr�)�prVrVrWrunsz_rmtree.<locals>.<lambda>)r�)rxrV)r�rW�_rmtree^sr�csWytj|�dSWntk
r)YnX�fdd���|�tj|�dS)Nc
s�x�t|tj|�D]�}tjj||�}ytj|�j}Wntk
rad}YnXtj	|�r��|�t|tj
|�qt|tj|�qWdS)Nr)r�rwr�rxr�r�r�r�r�r�r�r)rxrhr�r�)r�rVrWr�zs

z_rmtree.<locals>._rmtree_inner)�shutilrr�rwr�)rxrV)r�rWr�ss


cCs-yt|�Wnttfk
r(YnXdS)N)r��FileNotFoundError�NotADirectoryError)r�rVrVrWr�scCs'yt|�Wntk
r"YnXdS)N)r�r�)ryrVrVrWr��s
r�cCs'yt|�Wntk
r"YnXdS)N)r�r�)rxrVrVrWr�s
cCs]tjj|�}tjjtjj|��}tjj||d�}tj||�|S)N�c)	r_�util�cache_from_sourcerwrxry�abspathr��rename)�sourceZpyc_fileZup_oneZ
legacy_pycrVrVrW�make_legacy_pyc�s
r�cCsvt|�xetjD]Z}tjj||d�}t|d�x*dD]"}ttjj|d|��qHWqWdS)Nz.pyr��r�r��optimization)r�r�r�)	r
rarxrwr�rr_r�r�)rpryr��optrVrVrWr�s

cs�ttd�rtjSd}tjjd�rddl�ddl�d}d}G�fdd�d�j�}�j	j
}|j�}|s��j��|�}�j
j�}|j||�j|��j|��j|��}|s��j��t|j|@�s�d}n�tjdkr�dd	lm}	m�m}
m}dd
lm}|	j|d��}
|
j�dkr�d}naG�fd
d�d|�}|�}|
|�}|
j|�dks�|
j|�dkr�d}|s�y;ddlm}|�}|j�|j �|j!�Wnrt"k
r�}zRt#|�}t$|�dkrq|dd�d}dj%t&|�j'|�}WYdd}~XnX|t_(|t_tjS)N�resultr�rr�csCeZdZd�jjfd�jjfd�jjfgZdS)z*_is_gui_available.<locals>.USEROBJECTFLAGSZfInheritZ	fReserved�dwFlagsN)rSrTrU�wintypesZBOOL�DWORD�_fields_rV)�ctypesrVrW�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 managercs(eZdZd�fd�fgZdS)z._is_gui_available.<locals>.ProcessSerialNumberZ
highLongOfPSNZlowLongOfPSNN)rSrTrUr�rV)r�rVrW�ProcessSerialNumber�s	r�z#cannot run without OS X gui process)�Tk�2z [...]zTk unavailable due to {}: {}))�hasattr�_is_gui_availabler�rarbrcr�Zctypes.wintypesr��windllZuser32ZGetProcessWindowStationZWinErrorr�r�ZGetUserObjectInformationWZbyrefZsizeof�boolr�r�r�r�Zctypes.utilr�ZLoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcess�tkinterr�Zwithdraw�updateZdestroy�	Exceptionrg�len�format�typerS�reason)r�Z	UOI_FLAGSZWSF_VISIBLEr�Zdll�hZuofZneeded�resr�r�r�r�Zapp_servicesr�ZpsnZpsn_pr��root�eZ
err_stringrV)r�r�rWr��sh			"			

	
r�cCstdkp|tkS)N)r)�resourcerVrVrWrscCsWt|�s.|dkr"d|}t|��|dkrSt�rSttj��dS)Nz"Use of the %r resource not enabled�gui)rr	r�r�)r�rjrVrVrWr
s
cs��fdd�}|S)Ncs4tj�����fdd��}�|_|S)Nc
s�tj��kr�tj�jdd�d}y"ttt|jd���}Wntk
rdYnAX|�kr�djtt	���}t
jd�||f���||�S)N�-r�rrkz(%s version %s or higher required, not %s)rb�system�releaser�rd�map�int�
ValueErrorr�rgrerf)r��kw�version_txt�version�min_version_txt)r��min_version�sysnamerVrW�wrappers"
z:_requires_unix_version.<locals>.decorator.<locals>.wrapper)�	functools�wrapsr�)r�r�)r�r�)r�rW�	decorators'	z)_requires_unix_version.<locals>.decoratorrV)r�r�r�rV)r�r�rW�_requires_unix_versionsr�cGs
td|�S)NZFreeBSD)r�)r�rVrVrWr.scGs
td|�S)NZLinux)r�)r�rVrVrWr 7scs�fdd�}|S)Ncs1tj����fdd��}�|_|S)Ncs�tjdkr�tj�d}y"ttt|jd���}Wntk
rUYn>X|�kr�djtt	���}t
jd||f���||�S)Nr�rrkz&Mac OS X %s or higher required, not %s)rarbZmac_verrdr�r�r�r�r�rgrerf)r�r�r�r�r�)r�r�rVrWr�Hs"
z4requires_mac_ver.<locals>.decorator.<locals>.wrapper)r�r�r�)r�r�)r�)r�rWr�Gs$	z#requires_mac_ver.<locals>.decoratorrV)r�r�rV)r�rWr!@sz	127.0.0.1z::1cCs/tj||�}t|�}|j�~|S)N)�socketr?�close)�family�socktypeZtempsock�portrVrVrWr>bs
8
cCs
|jtjkr�|jtjkr�ttd�r]|jtjtj�dkr]t	d��ttd�r�dt
jkr�y.|jtjtj�dkr�t	d��Wnt
k
r�YnXttd�r�|jtjtjd�|j|df�|j�d}|S)	N�SO_REUSEADDRr�zHtests 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��
getsockopt�
SOL_SOCKETr�rrw�environr�r��
setsockoptr��bind�getsockname)�sock�hostr�rVrVrWr?�s $
cCsstjrod}zLy3tjtjtj�}|jtdf�dSWntk
rYYnXWd|rn|j�XdS)NrTF)r��has_ipv6�AF_INET6r�r��HOSTv6r�r�)r�rVrVrW�_is_ipv6_enabled�s	
	rcs%tj���fdd��}|S)Ncsay�||�WnItk
r\}z)dt|�krGtjd���WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)�IOErrorrgrerf)r��kwargsr�)rtrVrW�dec�sz&system_must_validate_cert.<locals>.dec)r�r�)rtrrV)rtrW�system_must_validate_cert�s!	rr�i�ZdoubleZIEEEztest requires IEEE 754 doublesz
requires zlibz
requires gzipzrequires bz2z
requires lzma�javaz$testz@testz	{}_{}_tmp�æ�İ�Ł�φ�К�א�،�ت�ก� �€u-àòɘŁğr�ZNFD�nt�cer�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}|dkr9tj�}d}tjj|�}nOytj|�d}Wn5tk
r�|si�tjd|t	dd�YnXz	|VWd|r�t
|�XdS)NFTz+tests may fail, unable to create temp dir: r��)�tempfile�mkdtemprwrx�realpath�mkdirr�rYr�r�r)rx�quietZdir_createdrVrVrW�temp_dir�s"



	r"ccsytj�}ytj|�Wn5tk
rT|s6�tjd|tdd�YnXztj�VWdtj|�XdS)Nz)tests may fail, unable to change CWD to: r�r)rw�getcwd�chdirr�rYr�r�)rxr!Z	saved_dirrVrVrW�
change_cwd�s


r%ZtempcwdccsDtd|d|��(}t|d|��}|VWdQRXWdQRXdS)Nrxr!)r"r%)rhr!Z	temp_pathZcwd_dirrVrVrWr�s�umaskccs-tj|�}z	dVWdtj|�XdS)N)rwr&)r&ZoldmaskrVrVrWrA�s	�datacCs�tjj|�r|S|dk	r7tjj||�}tgtj}x9|D]1}tjj||�}tjj|�rN|SqNW|S)N)rwrx�isabsr��
TEST_HOME_DIRra�exists)r�ZsubdirrxZdn�fnrVrVrWr�s
cCs4tj|tjtjBtjB�}tj|�dS)N)rw�open�O_WRONLY�O_CREAT�O_TRUNCr�)r��fdrVrVrWr�s#cCs<t|j��}dd�|D�}dj|�}d|S)NcSsg|]}d|�qS)z%r: %rrV)�.0ZpairrVrVrW�
<listcomp>s	zsortdict.<locals>.<listcomp>z, z{%s})�sortedr}r�)�dictr}Z	reprpairsZ
withcommasrVrVrWrQscCs9ttd�}z|j�SWd|j�tt�XdS)N�wb)r,r�filenor�r)r�rVrVrW�make_bad_fd	s

r7�lineno�offsetcCs�|jt��}t|dd�WdQRX|j}|j|j�|dk	ra|j|j|�|j|j�|dk	r�|j|j|�dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compile�	exceptionZassertIsNotNoner8�assertEqualr9)�testcaseZ	statementr8r9�cmr�rVrVrWr"s	cs�ddl}ddl}�jdd��|jj|�djd�d}tjjt	|�}���fdd�}tjj
|�r�||�}|dk	r�|St|�td�t
r�td	|d
t��|jj�}tr�|jjd�|j|d
d�}trC|jjd�dkrCtjd|�}zOt|d��9}	|j�}
x#|
r�|	j|
�|j�}
qgWWdQRXWd|j�X||�}|dk	r�|Std|��dS)Nr�checkr��/r�csMt|���}�dkr"|S�|�r?|jd�|S|j�dS)Nr)r,�seekr�)r+rt)r�rBr�rVrW�check_valid_file)s
z*open_urlresource.<locals>.check_valid_fileZurlfetchz	fetching %s ...r��Accept-Encoding�gzipr��zContent-Encoding�fileobjr5zinvalid resource %r���)rFrG)Zurllib.requestZurllib.parse�pop�parse�urlparser�rwrxr��
TEST_DATA_DIRr*rrrr�rZrequestZbuild_openerrGZ
addheadersr|r,Zheaders�getZGzipFile�read�writer�r)Zurlr�r��urllibr�r+rErtZopener�out�srV)r�rBr�rWr@ s<#	

	
c@sFeZdZdd�Zdd�Zedd��Zdd�Zd	S)
�WarningsRecordercCs||_d|_dS)Nr)�	_warnings�_last)�selfZ
warnings_listrVrVrW�__init__Vs	zWarningsRecorder.__init__cCs\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS)Nr�z%r has no attribute %rrJ)r�rVrWrrY�WarningMessage�_WARNING_DETAILSr�)rX�attrrVrVrW�__getattr__Zs
zWarningsRecorder.__getattr__cCs|j|jd�S)N)rVrW)rXrVrVrWrYaszWarningsRecorder.warningscCst|j�|_dS)N)r�rVrW)rXrVrVrW�reseteszWarningsRecorder.resetN)rSrTrUrYr]�propertyrYr^rVrVrVrWrURsrUc
cs^tjd�}|jjd�}|r1|j�tjdd��&}tjdjd�t	|�VWdQRXt
|�}g}x�|D]�\}}d}	xd|dd�D]R}|j}
tj
|t|
�tj�r�t|
j|�r�d}	|j|�q�W|	r�|r�|j||jf�q�W|r@td|d	��|rZtd
|d	��dS)Nr�Z__warningregistry__�recordTrY�alwaysFzunhandled warning %srz)filter (%r, %s) did not catch any warning)ra�	_getframe�	f_globalsrO�clearrYrZrl�simplefilterrUrn�message�re�matchrg�I�
issubclassr��remover|rS�AssertionError)�filtersr!�frame�registry�wZreraise�missingrj�cat�seen�warningrVrVrW�_filterwarningsis0
	rucOsC|jd�}|s6dtff}|dkr6d}t||�S)Nr!r�T)rO�Warningru)rmrr!rVrVrWrH�sccsOtjdd��&}tjddt�dVt�WdQRX|j|g�dS)Nr`Tra�category)rYrZr[�ResourceWarning�
gc_collectr?)r@ZwarnsrVrVrWrI�s
c@s4eZdZdd�Zdd�Zdd�ZdS)rcGsitjj�|_xP|D]H}|tjkrtj|}|j|krWtj|j=tj|=qWdS)N)rarl�copy�original_modulesrS)rX�module_names�module_namer~rVrVrWrY�s


zCleanImport.__init__cCs|S)NrV)rXrVrVrW�	__enter__�szCleanImport.__enter__cGstjj|j�dS)N)rarlr�r{)rX�
ignore_excrVrVrW�__exit__�szCleanImport.__exit__N)rSrTrUrYr~r�rVrVrVrWr�s
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rJcCstj|_i|_dS)N)rwr��_environ�_changed)rXrVrVrWrY�szEnvironmentVarGuard.__init__cCs|j|S)N)r�)rX�envvarrVrVrW�__getitem__�szEnvironmentVarGuard.__getitem__cCs9||jkr(|jj|�|j|<||j|<dS)N)r�r�rO)rXr��valuerVrVrW�__setitem__�szEnvironmentVarGuard.__setitem__cCsE||jkr(|jj|�|j|<||jkrA|j|=dS)N)r�r�rO)rXr�rVrVrW�__delitem__�szEnvironmentVarGuard.__delitem__cCs
|jj�S)N)r��keys)rXrVrVrWr��szEnvironmentVarGuard.keyscCs
t|j�S)N)�iterr�)rXrVrVrW�__iter__�szEnvironmentVarGuard.__iter__cCs
t|j�S)N)r�r�)rXrVrVrW�__len__�szEnvironmentVarGuard.__len__cCs|||<dS)NrV)rXr�r�rVrVrW�set�szEnvironmentVarGuard.setcCs||=dS)NrV)rXr�rVrVrW�unsetszEnvironmentVarGuard.unsetcCs|S)NrV)rXrVrVrWr~szEnvironmentVarGuard.__enter__cGsexR|jj�D]A\}}|dkrD||jkrQ|j|=q||j|<qW|jt_dS)N)r�r}r�rwr�)rXr�k�vrVrVrWr�s
zEnvironmentVarGuard.__exit__N)rSrTrUrYr�r�r�r�r�r�r�r�r~r�rVrVrVrWrJ�sc@s4eZdZdd�Zdd�Zdd�ZdS)�
DirsOnSysPathcGs6tjdd�|_tj|_tjj|�dS)N)rarx�original_value�original_object�extend)rX�pathsrVrVrWrYszDirsOnSysPath.__init__cCs|S)NrV)rXrVrVrWr~#szDirsOnSysPath.__enter__cGs&|jt_|jtjdd�<dS)N)r�rarxr�)rXrrVrVrWr�&szDirsOnSysPath.__exit__N)rSrTrUrYr~r�rVrVrVrWr�sr�c@s=eZdZdd�Zdd�Zddddd�ZdS)r#cKs||_||_dS)N)r��attrs)rXr�rrVrVrWrY0s	zTransientResource.__init__cCs|S)NrV)rXrVrVrWr~4szTransientResource.__enter__NcCst|dk	rpt|j|�rpxO|jj�D]2\}}t||�sJPt||�|kr.Pq.Wtd��dS)Nz%an optional resource is not available)rjr�r�r}r�rr	)rXZtype_r��	tracebackr\Z
attr_valuerVrVrWr�7szTransientResource.__exit__)rSrTrUrYr~r�rVrVrVrWr#+s�errnor�g>@�errnosc	#s�ddd 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
r�}z�xr|j
}t|�dkr_t
|dt�r_|d}q$t|�dkr�t
|dt�r�|d}q$Pq$W||��WYdd}~XnXWdtj|�XdS),N�ECONNREFUSED�o�
ECONNRESET�h�EHOSTUNREACH�q�ENETUNREACH�e�	ETIMEDOUT�n�	EAI_AGAINr�EAI_FAILr��
EAI_NONAMEr��
EAI_NODATA��
WSANO_DATA�*zResource %r is not availablecSs(g|]\}}tt||��qSrV)rr�)r1rh�numrVrVrWr2ds	z&transient_internet.<locals>.<listcomp>cSs(g|]\}}tt||��qSrV)rr�)r1rhr�rVrVrWr2fs	cs�t|dd�}t|tj�s�t|tj�rB|�ks�t|tjj�rvd|jkoqdkns�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��gaierrorrR�error�	HTTPError�code�URLErrorr�rra�stderrrQr�)r��n)�captured_errnos�denied�
gai_errnosrVrW�filter_erroris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��getdefaulttimeout�setdefaulttimeout�nntplibZNNTPTemporaryErrorrrar�rQr�r�r�r�)	Z
resource_namer�r�Zdefault_errnosZdefault_gai_errnosr�Zold_timeoutr��arV)r�r�r�rWr'LsN			
	

		%
%

c
cs[ddl}tt|�}tt||j��ztt|�VWdtt||�XdS)Nr)�iorra�setattr�StringIO)Zstream_namer�Zorig_stdoutrVrVrW�captured_output�sr�cCs
td�S)Nr�)r�rVrVrVrWr�scCs
td�S)Nr�)r�rVrVrVrWr�scCs
td�S)N�stdin)r�rVrVrVrWr�s
cCs5tj�trtjd�tj�tj�dS)Ng�������?)�gcZcollectr:r�r�rVrVrVrWry�s




ryc
cs7tj�}tj�z	dVWd|r2tj�XdS)N)r��	isenabled�disable�enable)Zhave_gcrVrVrW�
disable_gc�s
	r�cCsQtjd�pd}d}x)|j�D]}|jd�r(|}q(W|dkS)N�	PY_CFLAGSr�z-O�-O0�-Og)r�r�r�)�	sysconfig�get_config_varr�rc)ZcflagsZ	final_optr�rVrVrW�python_is_optimized�s
r�ZnPZ0n�gettotalrefcountZ2PZ0Pr�cCstjt|t�S)N)�struct�calcsize�_header�_align)�fmtrVrVrW�calcobjsize�sr�cCstjt|t�S)N)r�r��_vheaderr�)r�rVrVrW�calcvobjsize�sr���	cCs�ddl}tj|�}t|�tkr:|jt@s_t|�tkrlt|�jt@rl||j7}dt|�||f}|j|||�dS)Nrz&wrong size for %s: got %d, expected %d)	�	_testcapira�	getsizeofr��	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADr?)�test�o�sizer�r�rjrVrVrW�check_sizeof�s%
r�cs��fdd�}|S)Ncs4���fdd�}�j|_�j|_|S)Ncs�y.ddl}t|��}|j|�}Wn&tk
rE�YnCd}}Yn2Xx.�D]&}y|j||�PWq^Yq^Xq^Wz�||�SWd|r�|r�|j||�XdS)Nr)�localer�	setlocaler�)r��kwdsr�rwZorig_locale�loc)�catstrr��localesrVrW�inner	s$

	z1run_with_locale.<locals>.decorator.<locals>.inner)rS�__doc__)r�r�)r�r�)r�rWr�sz"run_with_locale.<locals>.decoratorrV)r�r�r�rV)r�r�rWrKscs�fdd�}|S)Ncs1��fdd�}�j|_�j|_|S)Ncs�y
tj}Wn!tk
r0tjd��YnXdtjkrPtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS)Nztzset requiredZTZ)r��tzsetr�rerfrwr�)r�r�r�Zorig_tz)r��tzrVrWr�-s




z-run_with_tz.<locals>.decorator.<locals>.inner)rSr�)r�r�)r�)r�rWr�,szrun_with_tz.<locals>.decoratorrV)r�r�rV)r�rWrR+sc	Cs�dddtdtddti}tjd|tjtjB�}|dkr`td|f��tt|j	d��||j	d	�j
��}|a|tkr�t}|t
dkr�td
|f��|adS)Nr�i�m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rr�rz$Memory limit %r too low to be useful)�_1M�_1Grgrh�
IGNORECASE�VERBOSEr�r��float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limitZsizesr��memlimitrVrVrWrOUs2c@s4eZdZdd�Zdd�Zdd�ZdS)�_MemoryWatchdogcCs(djdtj��|_d|_dS)Nz/proc/{pid}/statm�pidF)r�rw�getpid�procfile�started)rXrVrVrWrYosz_MemoryWatchdog.__init__cCs�yt|jd�}WnOtk
rg}z/tjdj|�t�tjj	�dSWYdd}~XnXt
d�}tjtj
|gd|dtj�|_|j�d|_dS)N�rz!/proc not available for stats: {}zmemory_watchdog.pyr�r�T)r,rr�rYr�r�r�rar��flushr�
subprocess�Popen�
executable�DEVNULL�mem_watchdogr�r)rXrtr�Zwatchdog_scriptrVrVrW�startss

z_MemoryWatchdog.startcCs'|jr#|jj�|jj�dS)N)rr�	terminate�wait)rXrVrVrW�stop�s	
z_MemoryWatchdog.stopN)rSrTrUrYrrrVrVrVrWrjsrcs���fdd�}|S)Ncs.���fdd����_��_�S)Nc
s��j}�j}ts!d}n|}ts4�r_t||kr_tjd||d��tr�tr�t�tdjd||d��t�}|j	�nd}z�||�SWd|r�|j
�XdS)	Niz'not enough memory: %.1fG minimum neededirz* ... expected peak memory use: {peak:.1f}GZpeaki@i@)r��memuser�rerfrr�r�rrr)rXr�r�maxsizeZwatchdog)�dry_runrtr�rVrWr��s*			
	
z.bigmemtest.<locals>.decorator.<locals>.wrapper)r�r)rt)rrr�)rtr�rWr��s		zbigmemtest.<locals>.decoratorrV)r�rrr�rV)rrr�rWr/�s
!cs�fdd�}|S)Ncs^ttkrPtd
kr6tdkr6tjd��qZtjdtd��n
�|�SdS)
Nr��?r��z-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededirll����li@)rr�rerf)rX)rtrVrWr��sz!bigaddrspacetest.<locals>.wrapperrV)rtr�rV)rtrWr0�sc@seZdZdd�ZdS)r(cCstj�}||�|S)N)reZ
TestResult)rXr�r�rVrVrW�run�s
zBasicTestRunner.runN)rSrTrUrrVrVrVrWr(�scCs|S)NrV)r�rVrVrW�_id�srcCsP|dkr&t�r&tjtj�St|�r6tStjdj|��SdS)Nr�zresource {0!r} is not enabled)r�re�skipr�rrr�)r�rVrVrW�requires_resource�s
rcCstdd�|�S)N�cpythonT)�impl_detail)r�rVrVrWr1�scKszt|�rtS|dkrmt|�\}}|r=d}nd}t|j��}|jdj|��}tj|�S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or )	r;r�
_parse_guardsr3r�r�r�rer)rj�guardsZ
guardnames�defaultrVrVrWr�s	rcCsjtdkrGddl}y|j�daWntk
rFdaYnXd}trW|Stj|�|�S)NrTFz6requires a functioning shared semaphore implementation)�_have_mp_queue�multiprocessing�Queuer`rer)r�rrjrVrVrWr9�s


cCs7|sddidfSt|j��d}||fS)NrTFr)rn�values)rZis_truerVrVrWr�srcKs.t|�\}}|jtj�j�|�S)N)rrOrbZpython_implementationr�)rrrVrVrWr;scs<ttd�s�Stj���fdd��}|SdS)N�gettracecs?tj�}ztjd��||�SWdtj|�XdS)N)rar"�settrace)r�rZoriginal_trace)r�rVrWr�s

zno_tracing.<locals>.wrapper)r�rar�r�)r�r�rV)r�rW�
no_tracings!r$cCstt|��S)N)r$r1)r�rVrVrW�
refcount_test#sr%cCsog}xY|jD]N}t|tj�rEt||�|j|�q||�r|j|�qW||_dS)N)Z_testsr�re�	TestSuite�
_filter_suiter|)�suiteZpredZnewtestsr�rVrVrWr'.s
r'cCs�tr'tjtjdddt�}n	t�}|j|�}|j�s�t	|j
�dkr~|jr~|j
dd}nIt	|j�dkr�|j
r�|jdd}nd}ts�|d7}t|��dS)N�	verbosityr�rr�rzmultiple errors occurredz!; run in verbose mode for details)
rreZTextTestRunnerrar�rr(rZ
wasSuccessfulr��errorsZfailuresr)r(Zrunnerr�r�rVrVrW�
_run_suite:s	
r+cCswtdkrdS|j�}xTtD]L}tj||�r?dSx-|jd�D]}tj||�rOdSqOWq#WdS)NTrkF)�match_tests�id�fnmatch�fnmatchcaser�)r�Ztest_idZ
match_testrhrVrVrW�_match_testNs
r0cGs�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wt|t�t
|�dS)Nz)str arguments must be keys in sys.modules)rer&ZTestCaser�rgrarlZaddTestZ
findTestCasesr�Z	makeSuiter'r0r+)�classesZvalid_typesr(�clsrVrVrWr)_s
 
cCsdS)NrVrVrVrVrW�_check_docstringsvsr3�win32�WITH_DOC_STRINGSztest requires docstringscCs�ddl}|dkr!t}nd}|j|d|d|�\}}|rdtd||f��tr�td|j|f�||fS)Nrr�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestr�testmodrr�rS)r~r)r6r7rtr�rVrVrWr*�s	!cCstjj�fS)N)rarlrzrVrVrVrW�
modules_setup�sr9cCsMdd�tjj�D�}tjj�tjj|�tjj|�dS)NcSs1g|]'\}}|jd�r||f�qS)z
encodings.)rc)r1r�r�rVrVrWr2�s		z#modules_cleanup.<locals>.<listcomp>)rarlr}rdr�)Z
oldmodules�	encodingsrVrVrW�modules_cleanup�s
r;cCs-trtj�tjj�fSdffSdS)Nr�)�_thread�_count�	threading�	_danglingrzrVrVrVrWrD�scGsats
dSd}xJt|�D]<}tj�tjf}||krEPtjd�t�qWdS)N�dg{�G�z�?)r<�ranger=r>r?r�r�ry)Zoriginal_valuesZ
_MAX_COUNT�countr!rVrVrWrE�s
cs/ts
�Stj���fdd��}|S)Ncs)t�}z�|�SWdt|�XdS)N)rDrE)r��key)r�rVrWr��s	zreap_threads.<locals>.decorator)r<r�r�)r�r�rV)r�rWrF�s!c	CsXttd�rTd}x<y,tj|tj�\}}|dkrCPWqPYqXqWdS)N�waitpidr�rrJ)r�rwrD�WNOHANG)Zany_processr�statusrVrVrWrB�s	ccsvt|�}g}ziy,x%|D]}|j�|j|�qWWn1trmtdt|�t|�f��YnXdVWdz�|r�|�tj�}}x�tdd�D]{}|d7}x.|D]&}|jt	|tj�d��q�Wdd�|D�}|s	Ptr�tdt|�|f�q�WWdd	d�|D�}|rpt
jtj
�td
t|���XXdS)Nz/Can't start %d threads, only %d threads startedr�r�<g{�G�z�?cSs"g|]}|j�r|�qSrV)�isAlive)r1r�rVrVrWr2s	z!start_threads.<locals>.<listcomp>z7Unable to join %d threads during a period of %d minutescSs"g|]}|j�r|�qSrV)rH)r1r�rVrVrWr2s	zUnable to join %d threads)rnrr|rr�r�r�rAr��max�faulthandlerZdump_tracebackrar�rl)�threadsZunlockrr��endtimeZ	starttimer�rVrVrWrG�s>

	

$c
cs�t||�rNt||�}t|||�z	|VWdt|||�Xn9t|||�z	dVWdt||�r�t||�XdS)N)r�rr��delattr)r�r\�new_val�real_valrVrVrWrMs		ccsh||kr:||}|||<z	|VWd|||<Xn*|||<z	dVWd||krc||=XdS)NrV)r��itemrNrOrVrVrWrL:s

	
	cCstjdd|�j�}|S)Ns\[\d+ refs, \d+ blocks\]\r?\n?�)rg�sub�strip)r�rVrVrW�strip_python_stderrYsrTZ	getcountsz-types are immortal if COUNT_ALLOCS is definedcCs
tj�S)N)r�_args_from_interpreter_flagsrVrVrVrW�args_from_interpreter_flagsfsrVc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rCcCs#tjjj|d�||_dS)Nr)�logging�handlers�BufferingHandlerrY�matcher)rXrZrVrVrWrYpszTestHandler.__init__cCsdS)NFrV)rXrVrVrW�shouldFlushyszTestHandler.shouldFlushcCs$|j|�|jj|j�dS)N)r��bufferr|�__dict__)rXr`rVrVrW�emit|s
zTestHandler.emitcKs:d}x-|jD]"}|jj||�rd}PqW|S)NFT)r\rZ�matches)rXrr��drVrVrWr_�szTestHandler.matchesN)rSrTrUrYr[r^r_rVrVrVrWrCos	c@s.eZdZdZdd�Zdd�ZdS)	rNrjrfcKsPd}xC|D];}||}|j|�}|j|||�s
d}Pq
W|S)NTF)rO�match_value)rXr`rr�r�r��dvrVrVrWr_�s

zMatcher.matchescCsjt|�t|�kr!d}nEt|�tk	sB||jkrQ||k}n|j|�dk}|S)NFr)r�rg�_partial_matches�find)rXr�rbr�r�rVrVrWra�s	!zMatcher.match_valueN)rjrf)rSrTrUrcr_rarVrVrVrWrN�sc
Csotdk	rtStd}ytjt|�d}Wn!tttfk
rWd}YnXtj|�|a|S)NrTF)�_can_symlinkrrw�symlinkr��NotImplementedErrorr�rk)Zsymlink_path�canrVrVrWr�s


cCs,t�}d}|r|Stj|�|�S)Nz*Requires functional symlink implementation)rrer)r��okrjrVrVrWr+�s	cCs	tdk	rtSttd�s(d}n�tj�\}}z�ttd���}yutj|dd�tj|j�dd�t	j
�}tjd|�}|dkp�t
|jd��dk}Wntk
r�d}YnXWdQRXWdtt�t|�X|a|S)	N�setxattrFr5s	user.testrQz
2.6.(\d{1,2})r��')�
_can_xattrr�rwr�mkstempr,rrjr6rbr�rgrhr�r�r�r)rhZtmp_fpZtmp_name�fpZkernel_versionr�rVrVrW�	can_xattr�s&	+

rocCs,t�}d}|r|Stj|�|�S)Nz(no non-broken extended attribute support)rorer)r�rirjrVrVrWr4�s	cCs}tjd|��d}|j}|j�}||krB|j�}ytjj||�SWntk
rqdSYnXWdQRXdS)N�dirF)	r�NamedTemporaryFilerh�upperr�rwrx�samefiler�)Z	directory�base�	base_pathZ	case_pathrVrVrWr�s	
rXcCsUtt|��tt|��}|r8|t|�8}tdd�|D��}|S)Ncss4|]*}|jd�s(|jd�r|VqdS)�_�__N)rc�endswith)r1r�rVrVrW�	<genexpr>�sz&detect_api_mismatch.<locals>.<genexpr>)r�rp)Zref_apiZ	other_apirXZ
missing_itemsrVrVrWr8�s
"c@s4eZdZdZdZdd�Zdd�ZdS)rPNc
Cs�tjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
r�Yq�Xi|_
xH|j|j|jgD]C}|j
||j�}|j||j�}||f|j
|<q�Wn�tdk	r]y9tjtj�|_tjtjd|jdf�Wnttfk
r\YnXtjdkr�dddd	g}tj|d
tjdtj�}|�|j�d}	WdQRX|	j�dkr�td
dddd�|S)Nr�rr�r�r�z/usr/bin/defaultsrPzcom.apple.CrashReporterZ
DialogTyper�r�s	developerz:this test triggers the Crash Reporter, that is intentional�endr�rT) rarbrcr�r�Zkernel32�_k32�SetErrorMode�	old_value�msvcrt�CrtSetReportModer�r`�	old_modesZCRT_WARNZ	CRT_ERRORZ
CRT_ASSERTZCRTDBG_MODE_FILE�CrtSetReportFileZCRTDBG_FILE_STDERRr�Z	getrlimit�RLIMIT_CORE�	setrlimitr�r�rr�PIPE�communicaterSr�)
rXr�ZSEM_NOGPFAULTERRORBOXr~�report_type�old_mode�old_file�cmd�procr�rVrVrWr~	sN						
zSuppressCrashReport.__enter__cGs�|jdkrdStjjd�r�|jj|j�|jr�ddl}x�|jj�D]2\}\}}|j	||�|j
||�q]WnAtdk	r�ytjtj
|j�Wnttfk
r�YnXdS)Nr�r)r}rarbrcr{r|r�r~r}rr�r�r�r�r�r�)rXrr~r�r�r�rVrVrWr�L	s	"zSuppressCrashReport.__exit__)rSrTrUr}r�r~r�rVrVrVrWrP	sAcs�t���d�y�j��Wn*ttfk
rPt��d��YnXd�����fdd�}|j|�t��|�dS)NFTcs*�rt����n
t���dS)N)r�rMrV)�
attr_is_local�	attr_name�object_to_patchr}rVrW�cleanupw	szpatch.<locals>.cleanup)rr]r�rrZ
addCleanupr�)Z
test_instancer�r�Z	new_valuer�rV)r�r�r�r}rW�patcha	s


r�cCsYyddl}Wntk
r$YnX|j�r@tjd��ddl}|j|�S)NrzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)�tracemallocr`Z
is_tracingrerfr��run_in_subinterp)r�r�r�rVrVrWr��	s
r�csbG��fdd�d|�}d�|||���|jtt��t�|j��dS)Ncs%eZdZ��fdd�ZdS)z%check_free_after_iterating.<locals>.Acs-d�yt��Wntk
r(YnXdS)NT)�next�
StopIteration)rX)�done�itrVrW�__del__�	s

z-check_free_after_iterating.<locals>.A.__del__N)rSrTrUr�rV)r�r�rVrW�A�	sr�F)r;r�r�ryZ
assertTrue)r�r�r2r�r�rV)r�r�rW�check_free_after_iterating�	s	r�ii@i@i@ii)r	r
rrr
rrrrrr)rr)rrrrri@ii)�rSr`�collections.abc�collections�
contextlibr�rJr.r�r�r_�importlib.utilZlogging.handlersrWr�rwrbrgr�r�r�r�rrar�rr�reZurllib.errorrRrYr<r>Zmultiprocessing.processr�zlibrG�bz2�lzmar��__all__r�rrrfr	�contextmanagerr]r
rqrsr6r7rr2rrrr�rr,r�rrr
r�rcr�r�r�r�rr�rr�rr�rrr�rr r!r<rr�r�r>r?rr=rrZ
SOCK_MAX_SIZEZ
skipUnlessr��
__getformat__r3r5r,r-r.r:rhrr�rZFS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorZTESTFN_UNICODEZunicodedata�	normalize�getfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversion�encode�UnicodeEncodeErrorr��decode�UnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr#rr"r%rr�rArxryr�rzZTEST_SUPPORT_DIRr)r�rNrrrQr7r"r@�objectrUrurHrIr�abc�MutableMappingrJr�r#r�r�r$r�r%r&r'r�rrrryr�r�r�r�r�r�r�r�r�r�rKrRr�r�r�Z_4Grr�rOrr/r0r(rrr1rrr9rr;r$r%r'r+r0r)r3r�ZMISSING_C_DOCSTRINGSr�ZHAVE_DOCSTRINGSZrequires_docstringsr*r9r;rDrErFrBrGrMrLrTZskipIfZrequires_type_collectingrVrXrYrCrNrerr+rlror4rr8rPr�r�r�rVrVrVrW�<module>st






										
2	
!		
J			>&			




	



!2' 5	J		



$#


	0

			#
		"
_"

?>