Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/thread-self/root/proc/self/root/usr/lib64/python2.7/test/support/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/proc/self/root/usr/lib64/python2.7/test/support/__init__.pyc

�
{fc=@s�
dZedkr!ed��nddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZWnek
r:dZnXddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d4d<d=d>d?d@g=ZdAZdefdB��YZdefdC��YZdefdD��YZdejfdE��YZ ej!e"dF��Z#e$dG�Z%dH�Z&dI�Z'd�d�e$dJ�Z(dK�Z)dLZ*dZ+dMa,dMa-e$Z.da/dN�Z0dO�Z1dP�Z2dQ�Z3e
jj4dR�r+e$dS�Z5dT�Z6dU�Z7dV�Z8nej9Z6ej:Z7dW�Z8dX�Z9dY�Z:dZ�Z;d[�Z<d\�Z=d]�Z>dd^�Z?d_�Z@d`ZAdaZBejCejDdb�ZEeAdc�ZFdd�ZGeG�ZHde�ZIdfZJdg�ZKd�ZLd�ZMe
jj4dk�ZNyeOe"ZPWneQk
r-e$ZPnXejRePdl�ZSdm�ZTdZUePrx�eVdn�eVdo�eVdp�eVdq�eVdr�eVds�eVdt�eVdu�eVdv�eVdw�eVdx�fD]XZWy7eWjXe
jY��jZe
jY��eWkr�e[�nWne[k
rq�XeWZUPq�Wnej\dkkr6dyZ]n�ej\dzkrNd{Z]n�d|Z]ePr�e^d}eO�rrd~Z_neOd~d�Z_e
jY�Z`eae
d��s�e
jb�d�d�kr�dZcq�edd��ZcyecjXd��Wneek
r�q�Xd�ecGHnd�jfe]ejg��Z]d�Zheji�Zjej!de$d���Zkej!e$d���Zlej!d�e$d���Zmejnjoejnjpeq��Zrejnjoer�Zsejnjtesd��Zudd��Zvd��Zwd��Zxd}ddd��Zydd��Zzd�e{fd���YZ|e$d��Z}ej!d���Z~ej!d���Zd&e{fd���YZ�d'ej�fd���YZ�d�e{fd���YZ�d*e{fd���YZ�ej!dAd�d���Z�ej!d���Z�d��Z�d��Z�d��Z�d��Z�d�Z�eae
d��r�d�e�Z�ne�d�Z�d��Z�d��Z�d�Z�d�Z�d��Z�d��Z�d��Z�d�Z�die�Z�d�e�Z�dhe�Z�e
j�Z�d��Z�d�e�d��Z�d�e�e"d��Z�d��Z�d0d�d���YZ�d��Z�d��Z�d��Z�dd��Z�d��Z�d��Z�d��Z�d��Z�da�da�d��Z�d��Z�d��Z�d��Z�e�d�e$�pW	e
jd�kpW	ej�d��Z�ejRe�d��Z�dd��Z�e$Z�d��Z�d��Z�d��Z�ej!d�d���Z�d��Z�ej!dd���Z�ej!d���Z�ej!d���Z�d��Z�ej�eae
d��d��Z�d��Z�d��Z�d�d��Z�ej!d���Z�d��Z�d@d�d���YZ�d��Z�d��Z�d�d�d���YZ�dS(�s7Supporting definitions for the Python regression tests.stest.supports3test.support must be imported from the test packagei����NtErrort
TestFailedt
TestDidNotRuntResourceDeniedt
import_moduletverboset
use_resourcest
max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestrequires_mac_vertfind_unused_portt	bind_porttfcmpthave_unicodet	is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningstCleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localetset_memlimitt
bigmemtesttbigaddrspacetesttBasicTestRunnertrun_unittesttrun_doctesttthreading_setuptthreading_cleanuptreap_threadst
start_threadstcpython_onlytcheck_impl_detailt
get_attributet
py3k_bytestimport_fresh_modulet
reap_childrentstrip_python_stderrtIPV6_ENABLEDtrun_with_tztSuppressCrashReportg>@cBseZdZRS(s*Base class for regression test exceptions.(t__name__t
__module__t__doc__(((s-/usr/lib64/python2.7/test/support/__init__.pyR4scBseZdZRS(sTest failed.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR7scBseZdZRS(sTest did not run any subtests.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR:scBseZdZRS(s�Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not been enabled.  It is used to distinguish between expected
    and unexpected skips.
    (R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR=sccs=|r4tj��tjddt�dVWdQXndVdS(s�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.tignores.+ (module|package)N(twarningstcatch_warningstfilterwarningstDeprecationWarning(R?((s-/usr/lib64/python2.7/test/support/__init__.pyt_ignore_deprecated_importsEs
c	CsSt|��Aytj|�SWn(tk
rH}tjt|���nXWdQXdS(s�Import and return the module to be tested, raising SkipTest if
    it is not available.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDt	importlibRtImportErrortunittesttSkipTesttstr(tnamet
deprecatedtmsg((s-/usr/lib64/python2.7/test/support/__init__.pyRTs

cCs�|tjkr&t|�tj|=nxTttj�D]C}||ks[|j|d�r6tj|||<tj|=q6q6WdS(swHelper function to save and remove a module from sys.modules

       Raise ImportError if the module can't be imported.t.N(tsystmodulest
__import__tlistt
startswith(RJtorig_modulestmodname((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_remove_moduleas

cCsFt}ytj|||<Wntk
r4t}nXdtj|<|S(s�Helper function to save and block a module in sys.modules

       Return True if the module was in sys.modules, False otherwise.N(tTrueRNROtKeyErrortFalsetNone(RJRStsaved((s-/usr/lib64/python2.7/test/support/__init__.pyt_save_and_block_modulens


cCs�t|���i}g}t||�zyax|D]}t||�q3Wx-|D]%}t||�sQ|j|�qQqQWtj|�}Wntk
r�d}nXWdx'|j�D]\}	}
|
t	j
|	<q�Wx|D]}t	j
|=q�WX|SWdQXdS(sImports and returns a module, deliberately bypassing the sys.modules cache
    and importing a fresh copy of the module. Once the import is complete,
    the sys.modules cache is restored to its original state.

    Modules named in fresh are also imported anew if needed by the import.
    If one of these modules can't be imported, None is returned.

    Importing of modules named in blocked is prevented while the fresh import
    takes place.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.N(RDRUR[tappendRERRFRYtitemsRNRO(RJtfreshtblockedRKRStnames_to_removet
fresh_nametblocked_nametfresh_modulet	orig_nametmoduletname_to_remove((s-/usr/lib64/python2.7/test/support/__init__.pyR6{s&





cCs�yt||�}Wn�tk
r�t|tj�rKd|j|f}n�t|tj�rsd|j|f}nit|tj�r�d|jj|f}n>t|t	�r�d|j|f}ndt	|�j|f}t
j|��nX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %r has no attribute %rsclass %s has no attribute %rs%s instance has no attribute %rs"type object %r has no attribute %rs%r object has no attribute %rN(tgetattrtAttributeErrort
isinstancettypest
ModuleTypeR<t	ClassTypetInstanceTypet	__class__ttypeRGRH(tobjRJt	attributeRL((s-/usr/lib64/python2.7/test/support/__init__.pyR4�s
iicCs
|adS(N(t_original_stdout(tstdout((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs
tptjS(N(RrRNRs(((s-/usr/lib64/python2.7/test/support/__init__.pyR	�scCs&ytj|=Wntk
r!nXdS(N(RNRORW(RJ((s-/usr/lib64/python2.7/test/support/__init__.pyR
�s
cGsxy||�SWnctk
rs}tdkrVd|jj|fGHd|j|fGHntj|tj�||�SXdS(Nis%s: %ssre-run %s%r(tEnvironmentErrorRRnR<tostchmodtstattS_IRWXU(tpathtfunctargsterr((s-/usr/lib64/python2.7/test/support/__init__.pyt
_force_run�stwincCs�||�|r|}n$tjj|�\}}|p:d}d}xR|dkr�tj|�}|rm|n	||ks}dStj|�|d9}qFWtjd|tdd�dS(NRMg����MbP?g�?is)tests may fail, delete still pending for t
stackleveli(	RuRytsplittlistdirttimetsleepR@twarntRuntimeWarning(RztpathnametwaitalltdirnameRJttimeouttL((s-/usr/lib64/python2.7/test/support/__init__.pyt_waitfor�s
	

cCsttj|�dS(N(R�RuR(tfilename((s-/usr/lib64/python2.7/test/support/__init__.pyt_unlink�scCsttj|�dS(N(R�Rutrmdir(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt_rmdir�scs6�fd��t�|dt�td�|�dS(Ncs�x�t|tj|�D]i}tjj||�}tjj|�rlt�|dt�t|tj|�qt|tj	|�qWdS(NR�(
R}RuR�RytjointisdirR�RVR�R(RyRJtfullname(t
_rmtree_inner(s-/usr/lib64/python2.7/test/support/__init__.pyR�sR�cSst|tj|�S(N(R}RuR�(tp((s-/usr/lib64/python2.7/test/support/__init__.pyt<lambda>	t(R�RV(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyt_rmtree�scsSytj|�dSWntk
r(nX�fd���|�tj|�dS(Ncs�x�t|tj|�D]�}tjj||�}ytj|�j}Wntk
r`d}nXtj	|�r��|�t|tj
|�qt|tj|�qWdS(Ni(R}RuR�RyR�tlstattst_modeRtRwtS_ISDIRR�R(RyRJR�tmode(R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�s


(tshutilRRtRuR�(Ry((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�s


cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�tOSErrorterrnotENOENTtENOTDIR(R�texc((s-/usr/lib64/python2.7/test/support/__init__.pyR$s
cCs@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(R�R�R�R�(R�terror((s-/usr/lib64/python2.7/test/support/__init__.pyR�+s
cCsIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R�R�R�R�tESRCH(Ryte((s-/usr/lib64/python2.7/test/support/__init__.pyR3s
cCsjt|�xYtjD]N}ttjj||tjd��ttjj||tjd��qWdS(sm"Forget" a module was ever imported by removing it from sys.modules and
    deleting any .pyc and .pyo files.tpyctpyoN(R
RNRyRRuR�textsep(RTR�((s-/usr/lib64/python2.7/test/support/__init__.pyR
;s
$cs�ttd�rtjSd}tjjd�r ddl�ddl�d}d}d�j	f�fd��Y}�j
j}|j�}|s��j
��n|�}�jj�}|j||�j|��j|��j|��}|s�j
��nt|j|@�s�d}q�n�tjdkr�dd	lm}	m�m}
m	}dd
lm}|	j|d��}
|
j�dkr�d
}q�d|f�fd��Y}|�}|
|�}|
j|�dks�|
j|�dkr�d}q�n|s�y;ddlm}|�}|j �|j!�|j"�Wq�t#k
r�}t$|�}t%|�dkrz|d d}ndj&t'|�j(|�}q�Xn|t_)|t_tjS(NtresultR~i����itUSEROBJECTFLAGScs;eZd�jjfd�jjfd�jjfgZRS(tfInheritt	fReservedtdwFlags(R<R=twintypestBOOLtDWORDt_fields_((tctypes(s-/usr/lib64/python2.7/test/support/__init__.pyR�Rss,gui not available (WSF_VISIBLE flag not set)tdarwin(tcdlltc_inttpointert	Structure(tfind_librarytApplicationServicesis0gui tests cannot run without OS X window managertProcessSerialNumbercs eZd�fd�fgZRS(t
highLongOfPSNtlowLongOfPSN(R<R=R�((R�(s-/usr/lib64/python2.7/test/support/__init__.pyR�ts	s#cannot run without OS X gui process(tTki2s [...]sTk unavailable due to {}: {}(*thasattrt_is_gui_availableR�RYRNtplatformRRR�tctypes.wintypesR�twindlltuser32tGetProcessWindowStationtWinErrorR�R�tGetUserObjectInformationWtbyreftsizeoftboolR�R�R�R�tctypes.utilR�tLoadLibrarytCGMainDisplayIDtGetCurrentProcesstSetFrontProcesstTkinterR�twithdrawtupdatetdestroyt	ExceptionRItlentformatRoR<treason(R�t	UOI_FLAGStWSF_VISIBLER�tdllthtuoftneededtresR�R�R�R�tapp_servicesR�tpsntpsn_pR�trootR�t
err_string((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR�Gsh		"			

	
cCstdkp|tkS(s�Test whether a resource is enabled.

    Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    N(RRY(tresource((s-/usr/lib64/python2.7/test/support/__init__.pyR�scCs`t|�s4|dkr%d|}nt|��n|dkr\t�r\ttj��ndS(s@Raise ResourceDenied if the specified resource is not available.s$Use of the `%s' resource not enabledtguiN(RRYRR�R�(R�RL((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cs�fd�}|S(s�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    cs.tj����fd��}�|_|S(Ncs�tjdkr�tj�d}y"ttt|jd���}Wntk
rTq�X|�kr�djtt	���}t
jd||f��q�n�||�S(NR�iRMs&Mac OS X %s or higher required, not %s(RNR�tmac_verttupletmaptintR�t
ValueErrorR�RIRGRH(R{tkwtversion_txttversiontmin_version_txt(Rztmin_version(s-/usr/lib64/python2.7/test/support/__init__.pytwrapper�s"
(t	functoolstwrapsR�(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyt	decorator�s!	((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR�ss	127.0.0.1s::1cCs/tj||�}t|�}|j�~|S(s�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    socket.error will be raised at some point (depending on the platform and
    the order bind and listen were called on each socket).

    However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE
    will ever be raised when attempting to bind two identical host/ports. When
    accept() is called on each socket, the second caller's process will steal
    the port from the first caller, leaving them both in an awkwardly wedged
    state where they'll no longer respond to any signals or graceful kills, and
    must be forcibly killed via OpenProcess()/TerminateProcess().

    The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option
    instead of SO_REUSEADDR, which effectively affords the same semantics as
    SO_REUSEADDR on Unix.  Given the propensity of Unix developers in the Open
    Source world compared to Windows ones, this is a common mistake.  A quick
    look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when
    openssl.exe is called with the 's_server' option, for example. See
    http://bugs.python.org/issue2550 for more info.  The following site also
    has a very thorough description about the implications of both REUSEADDR
    and EXCLUSIVEADDRUSE on Windows:
    http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx)

    XXX: although this approach is a vast improvement on previous attempts to
    elicit unused ports, it rests heavily on the assumption that the ephemeral
    port returned to us by the OS won't immediately be dished back out to some
    other process when we close and delete our temporary socket but before our
    calling code has a chance to bind the returned port.  We can deal with this
    issue if/when we come across it.(tsocketRtclose(tfamilytsocktypettempsocktport((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
6
cCs|jtjkr�|jtjkr�ttd�rc|jtjtj�dkrct	d��qcnttd�r�y1|jtjtj
�dkr�t	d��nWq�tk
r�q�Xnttd�r�|jtjtj
d�q�n|j|df�|j�d}|S(s%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    tSO_REUSEADDRisHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!tSO_REUSEPORTsHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!tSO_EXCLUSIVEADDRUSEi(R�R�tAF_INETRotSOCK_STREAMR�t
getsockoptt
SOL_SOCKETR�RR�Rtt
setsockoptR�tbindtgetsockname(tsockthostR�((s-/usr/lib64/python2.7/test/support/__init__.pyRs$
cCs{tjrwd}zNy3tjtjtj�}|jtdf�tSWntjk
r[nXWd|rs|j	�nXnt
S(s+Check whether IPv6 is enabled on this host.iN(R�thas_ipv6RYtAF_INET6R�RtHOSTv6RVR�R�RX(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_ipv6_enabled$s	cs"tj���fd��}|S(s5Skip the test on TLS certificate validation failures.csRy�||�Wn:tk
rM}dt|�krGtjd��n�nXdS(NtCERTIFICATE_VERIFY_FAILEDs.system does not contain necessary certificates(tIOErrorRIRGRH(R{tkwargsR�(tf(s-/usr/lib64/python2.7/test/support/__init__.pytdec7s(R�R�(RR((Rs-/usr/lib64/python2.7/test/support/__init__.pytsystem_must_validate_cert5s	g���ư>cCs#t|t�st|t�rcy8t|�t|�t}t||�|krUdSWqqXn�t|�t|�krt|ttf�rxPttt	|�t	|���D]-}t
||||�}|dkr�|Sq�Wt	|�t	|�kt	|�t	|�kS||k||kS(Ni(RitfloattabsRRoR�RQtrangetminR�R(txtytfuzztitoutcome((s-/usr/lib64/python2.7/test/support/__init__.pyRDs-(,iiitjavasno unicode supportcCs
t|d�S(Nsunicode-escape(tunicode(ts((s-/usr/lib64/python2.7/test/support/__init__.pytumsi�i0iAi�ii�ii*ii�i� s$testtriscosttestfiles@testR�s@test-��slatin-1tgetwindowsversioniis'u"@test-\u5171\u6709\u3055\u308c\u308b"tLatin1sgWARNING: The filename %r CAN be encoded by the filesystem.  Unicode filename tests may not be effectives	{}_{}_tmpshttp://www.pythontest.netccsQt}|dkrEddl}|j�}t}tjj|�}n�tr�t	|t
�r�tjjr�y|jt
j�pd�}Wq�tk
r�|s�tjd��q�q�Xnytj|�t}Wn7tk
r|s��ntjd|tdd�nX|rtj�}nz	|VWd|rL|tj�krLt|�nXdS(s�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    i����Ntasciis;unable to encode the cwd name with the filesystem encoding.s+tests may fail, unable to create temp dir: Ri(RXRYttempfiletmkdtempRVRuRytrealpathRRiRtsupports_unicode_filenamestencodeRNtgetfilesystemencodingtUnicodeEncodeErrorRGRHtmkdirR�R@R�R�tgetpidR(Rytquiettdir_createdR tpid((s-/usr/lib64/python2.7/test/support/__init__.pyttemp_dir�s6





	ccs{tj�}ytj|�Wn7tk
rV|s9�ntjd|tdd�nXztj�VWdtj|�XdS(sgReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    s)tests may fail, unable to change CWD to: RiN(RutgetcwdtchdirR�R@R�R�(RyR)t	saved_dir((s-/usr/lib64/python2.7/test/support/__init__.pyt
change_cwds


ttempcwdc	csBtd|d|��'}t|d|��}|VWdQXWdQXdS(s�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    RyR)N(R,R0(RJR)t	temp_pathtcwd_dir((s-/usr/lib64/python2.7/test/support/__init__.pyR&stdatacCs�tjj|�r|S|dk	r:tjj||�}ntgtj}x9|D]1}tjj||�}tjj|�rQ|SqQW|S(s�Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).N(RuRytisabsRYR�t
TEST_HOME_DIRRNtexists(tfiletsubdirRytdntfn((s-/usr/lib64/python2.7/test/support/__init__.pyRAs
cCsJ|j�}|j�g|D]}d|^q}dj|�}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(R]tsortR�(tdictR]tpairt	reprpairst
withcommas((s-/usr/lib64/python2.7/test/support/__init__.pyROs

cCs9ttd�}z|j�SWd|j�tt�XdS(s`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    twbN(topenRtfilenoR�R(R8((s-/usr/lib64/python2.7/test/support/__init__.pytmake_bad_fdWs

cCs||jt|��}t|dd�WdQX|j}|dk	rV|j|j|�n|dk	rx|j|j|�ndS(Ns
<test string>texec(tassertRaisesRegexptSyntaxErrortcompilet	exceptionRYtassertEqualtlinenotoffset(ttestcaset	statementterrtextRKRLtcmR|((s-/usr/lib64/python2.7/test/support/__init__.pyRcs	c
sSddl}ddl}|j|�djd�d}tjjt|�}�fd�}tjj|�r�||�}|dk	r�|St	|�nt
d�t�d|IJ|j|dd�}zNt
|d	��9}|j�}	x#|	r
|j|	�|j�}	q�WWdQXWd|j�X||�}|dk	r?|Std
|��dS(Ni����it/csGt|�}�dkr|S�|�r9|jd�|S|j�dS(Ni(RBRYtseekR�(R;R(tcheck(s-/usr/lib64/python2.7/test/support/__init__.pytcheck_valid_filess
turlfetchs	fetching %s ...R�iRAsinvalid resource "%s"(turlparseturllib2R�RuRyR�t
TEST_DATA_DIRR7RYRRR	turlopenRBtreadtwriteR�R(
turlRSRVRWR�R;RTRtoutR((RSs-/usr/lib64/python2.7/test/support/__init__.pyRls. 	

	
tWarningsRecordercBs8eZdZd�Zd�Zed��Zd�ZRS(syConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS(Ni(t	_warningst_last(tselft
warnings_list((s-/usr/lib64/python2.7/test/support/__init__.pyt__init__�s	cCs\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS(Ni����s%r has no attribute %r(	R�R_R`RgR@tWarningMessaget_WARNING_DETAILSRYRh(Ratattr((s-/usr/lib64/python2.7/test/support/__init__.pyt__getattr__�s
cCs|j|jS(N(R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR@�scCst|j�|_dS(N(R�R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pytreset�s(R<R=R>RcRgtpropertyR@Rh(((s-/usr/lib64/python2.7/test/support/__init__.pyR^�s
		c
csptjd�}|jjd�}|r4|j�ntjdt��&}tjdj	d�t
|�VWdQXg|D]}|j^qu}g}x�|D]�\}}	t}
x[|D]R}t
|�}tj||tj�r�t|j|	�r�t}
|j|�q�q�W|
r�|r�|j||	jf�q�q�W|rOtd|d��n|rltd	|d��ndS(
s�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    it__warningregistry__trecordR@talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RNt	_getframet	f_globalstgettclearR@RARVROtsimplefilterR^tmessageRXRItretmatchtIt
issubclassRntremoveR\R<tAssertionError(
tfiltersR)tframetregistrytwtwarningtreraisetmissingRLtcattseenR�Rr((s-/usr/lib64/python2.7/test/support/__init__.pyt_filterwarnings�s0
cOsI|jd�}|s<dtff}|dkr<t}q<nt||�S(s�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    R)R�N(RotWarningRYRVR�(RyR
R)((s-/usr/lib64/python2.7/test/support/__init__.pyR�scOs@tjr$|s*dtff}q*nd}t||jd��S(sjContext manager to silence py3k warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default False)

    Without argument, it defaults to:
        check_py3k_warnings(("", DeprecationWarning), quiet=False)
    R�R)((RNtpy3kwarningRCR�Ro(RyR
((s-/usr/lib64/python2.7/test/support/__init__.pyR �s
	cBs)eZdZd�Zd�Zd�ZRS(s,Context manager to force import to return a new module reference.

    This is useful for testing module-level behaviours, such as
    the emission of a DeprecationWarning on import.

    Use like this:

        with CleanImport("foo"):
            importlib.import_module("foo") # new reference
    cGsotjj�|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(RNROtcopytoriginal_modulesR<(Ratmodule_namestmodule_nameRe((s-/usr/lib64/python2.7/test/support/__init__.pyRcs

cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyt	__enter__scGstjj|j�dS(N(RNROR�R�(Rat
ignore_exc((s-/usr/lib64/python2.7/test/support/__init__.pyt__exit__s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR!s
	
	cBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS(N(Rutenviront_environt_changed(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRc(scCs|j|S(N(R�(Ratenvvar((s-/usr/lib64/python2.7/test/support/__init__.pyt__getitem__,scCs<||jkr+|jj|�|j|<n||j|<dS(N(R�R�Ro(RaR�tvalue((s-/usr/lib64/python2.7/test/support/__init__.pyt__setitem__/scCsK||jkr+|jj|�|j|<n||jkrG|j|=ndS(N(R�R�Ro(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyt__delitem__5scCs
|jj�S(N(R�tkeys(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�<scCs|||<dS(N((RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytset?scCs||=dS(N((RaR�((s-/usr/lib64/python2.7/test/support/__init__.pytunsetBscCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�EscGshxU|jj�D]D\}}|dkrG||jkrT|j|=qTq||j|<qW|jt_dS(N(R�R]RYR�RuR�(RaR�tktv((s-/usr/lib64/python2.7/test/support/__init__.pyR�Hs(R<R=R>RcR�R�R�R�R�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR"#s								t
DirsOnSysPathcBs)eZdZd�Zd�Zd�ZRS(s�Context manager to temporarily add directories to sys.path.

    This makes a copy of sys.path, appends any directories given
    as positional arguments, then reverts sys.path to the copied
    settings when the context ends.

    Note that *all* sys.path modifications in the body of the
    context manager, including replacement of the object,
    will be reverted at the end of the block.
    cGs-tj|_tj|_tjj|�dS(N(RNRytoriginal_valuetoriginal_objecttextend(Ratpaths((s-/usr/lib64/python2.7/test/support/__init__.pyRc^s
cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�cscGs|jt_|jtj(dS(N(R�RNRyR�(RaR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�fs(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�Rs
		cBs2eZdZd�Zd�Zdddd�ZRS(s�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS(N(R�tattrs(RaR�R
((s-/usr/lib64/python2.7/test/support/__init__.pyRcps	cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR�tscCs}|dk	ryt|j|�ryxX|jj�D]8\}}t||�sMPnt||�|kr.Pq.q.Wtd��ndS(s�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).s%an optional resource is not availableN(RYRvR�R�t	iteritemsR�RgR(Rattype_R�t	tracebackRft
attr_value((s-/usr/lib64/python2.7/test/support/__init__.pyR�wsN(R<R=R>RcR�RYR�(((s-/usr/lib64/python2.7/test/support/__init__.pyR%ks		c#s�dddd d!d"g}d#d$d%d&d'g}td|��|�g��s�g|D]\}}tt||�^qV�g|D]\}}tt||�^q��n���fd�}tj�}z�y%|dk	r�tj|�ndVWn�tk
r�}	xxtr}|	j	}
t
|
�dkrGt|
dt�rG|
d}	qt
|
�dkryt|
dt�ry|
d}	qPqW||	��nXWdtj|�XdS((s�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.tECONNREFUSEDiot
ECONNRESETihtEHOSTUNREACHiqtENETUNREACHiet	ETIMEDOUTint
EADDRNOTAVAILict	EAI_AGAINi����tEAI_FAILi����t
EAI_NONAMEi����t
EAI_NODATAi����t
WSANO_DATAi�*sResource '%s' is not availablecst|dd�}t|tj�sNt|tj�rB|�ksN|�kr{tsrtjj	�j
dd�n��ndS(NR�is
(RgRYRiR�R�tgaierrorRRNtstderrR[R{(R|tn(tcaptured_errnostdeniedt
gai_errnos(s-/usr/lib64/python2.7/test/support/__init__.pytfilter_error�sNiii(R�io(R�ih(R�iq(R�ie(R�in(R�ic(R�i����(R�i����(R�i����(R�i����(R�i�*(RRgR�R�tgetdefaulttimeoutRYtsetdefaulttimeoutR	RVR{R�Ri(t
resource_nameR�terrnostdefault_errnostdefault_gai_errnosRJtnumR�told_timeoutR|ta((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR&�sJ		(+				%
%

ccs[ddl}tt|�}tt||j��ztt|�VWdtt||�XdS(s�Return a context manager used by captured_stdout and captured_stdin
    that temporarily replaces the sys stream *stream_name* with a StringIO.i����N(tStringIORgRNtsetattr(tstream_nameR�torig_stdout((s-/usr/lib64/python2.7/test/support/__init__.pyR#�scCs
td�S(s�Capture the output of sys.stdout:

       with captured_stdout() as s:
           print "hello"
       self.assertEqual(s.getvalue(), "hello")
    Rs(R#(((s-/usr/lib64/python2.7/test/support/__init__.pyR$�scCs
td�S(NR�(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stderr�scCs
td�S(Ntstdin(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stdin�scCs8tj�tr tjd�ntj�tj�dS(s�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    g�������?N(tgctcollectRR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt
gc_collect�s



t2PtgettotalrefcounttPcCstjt|d�S(Nt0P(tstructtcalcsizet_header(tfmt((s-/usr/lib64/python2.7/test/support/__init__.pytcalcobjsize�scCstjt|d�S(NR�(R�R�t_vheader(R�((s-/usr/lib64/python2.7/test/support/__init__.pytcalcvobjsize�sii	cCs�ddl}tj|�}t|�tkr:|jt@s_t|�tkrot|�jt@ro||j7}ndt|�||f}|j|||�dS(Ni����s&wrong size for %s: got %d, expected %d(	t	_testcapiRNt	getsizeofRot	__flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADRJ(ttesttotsizeR�R�RL((s-/usr/lib64/python2.7/test/support/__init__.pytcheck_sizeofs%cs��fd�}|S(Ncs1���fd�}�j|_�j|_|S(Ncs�y.ddl}t|��}|j|�}Wn$tk
rD�nAd}}n1Xx-�D]%}y|j||�PWq\q\Xq\Wz�||�SWd|r�|r�|j||�nXdS(Ni����(tlocaleRgt	setlocaleRhRY(R{tkwdsR�tcategorytorig_localetloc(tcatstrRztlocales(s-/usr/lib64/python2.7/test/support/__init__.pytinners$

(t	func_nameR>(RzR�(R�R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�s((R�R�R�((R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR'scs�fd�}|S(Ncs.��fd�}�j|_�j|_|S(Ncs�y
tj}Wn tk
r/tjd��nXdtjkrOtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS(Nstzset requiredtTZ(R�ttzsetRhRGRHRuR�RY(R{R�R�torig_tz(Rzttz(s-/usr/lib64/python2.7/test/support/__init__.pyR�;s




(R<R>(RzR�(R�(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR�:s((R�R�((R�s-/usr/lib64/python2.7/test/support/__init__.pyR:9scCs�idd6td6td6dtd6}tjd|tjtjB�}|dkrgtd|f��ntt	|j
d��||j
d	�j��}|a|t
kr�t
}n|tdkr�td
|f��n|adS(NiR�tmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRsRtt
IGNORECASEtVERBOSERYR�R�Rtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesR�tmemlimit((s-/usr/lib64/python2.7/test/support/__init__.pyR(bs 2	ics���fd�}|S(sQDecorator for bigmem tests.

    'minsize' is the minimum useful size for the test (in arbitrary,
    test-interpreted units.) 'memuse' is the number of 'bytes per size' for
    the test, or a good estimate of it. 'overhead' specifies fixed overhead,
    independent of the testsize, and defaults to 5Mb.

    The decorator tries to guess a good value for 'size' and passes it to
    the decorated test function. If minsize * memuse is more than the
    allowed memory use (as defined by max_memuse), the test is skipped.
    Otherwise, minsize is adjusted upward to use up to max_memuse.
    cs7����fd�}�|_�|_�|_|S(Ncs�ts.d}|j|��dtk�n^tt���}|�krutrqtjjd�jf�ndSt	|dt��}�||�S(Niis)Skipping %s because of memory constraint
i2(
RtassertFalseR�R�RRNR�R[R<tmax(Ratmaxsize(Rtmemusetminsizetoverhead(s-/usr/lib64/python2.7/test/support/__init__.pyR��s"(R�R�R�(RR�(R�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�R�((R�R�R�s-/usr/lib64/python2.7/test/support/__init__.pyR)ws
cs����fd�}|S(Ncs7����fd�}�|_�|_�|_|S(Ncsftsd}n�}ts"�rYt|�krYtrUtjjd�jf�ndS�||�S(Nis)Skipping %s because of memory constraint
(R�RRNR�R[R<(RaR�(tdry_runRR�R�(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	
(R�R�R�(RR�(RR�R�R�(Rs-/usr/lib64/python2.7/test/support/__init__.pyR��s
			((R�R�R�RR�((RR�R�R�s-/usr/lib64/python2.7/test/support/__init__.pytprecisionbigmemtest�scs�fd�}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjd�jf�q<n
�|�SdS(Ns)Skipping %s because of memory constraint
(RR�RRNR�R[R<(Ra(R(s-/usr/lib64/python2.7/test/support/__init__.pyR��s
((RR�((Rs-/usr/lib64/python2.7/test/support/__init__.pyR*�scBseZd�ZRS(cCstj�}||�|S(N(RGt
TestResult(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrun�s
(R<R=R(((s-/usr/lib64/python2.7/test/support/__init__.pyR+�scCs|S(N((Rp((s-/usr/lib64/python2.7/test/support/__init__.pyt_id�scCsP|dkr&t�r&tjtj�St|�r6tStjdj|��SdS(NR�sresource {0!r} is not enabled(R�RGtskipR�RRR�(R�((s-/usr/lib64/python2.7/test/support/__init__.pytrequires_resource�s
cCstdt�|�S(s9
    Decorator for tests only applicable on CPython.
    tcpython(timpl_detailRV(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR2�scKs}t|�rtS|dkrpt|�\}}|r=d}nd}t|j��}|jdj|��}ntj	|�S(Ns*implementation detail not available on {0}s%implementation detail specific to {0}s or (
R3RRYt
_parse_guardstsortedR�R�R�RGR(RLtguardst
guardnamestdefault((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	cCsW|sitd6tfS|j�d}|j�|gt|�ksLt�||fS(NRi(RVRXtvaluesR�Rx(Rtis_true((s-/usr/lib64/python2.7/test/support/__init__.pyR	�s
%cKs.t|�\}}|jtj�j�|�S(s5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    (R	RoR�tpython_implementationR�(RR
((s-/usr/lib64/python2.7/test/support/__init__.pyR3�scCsrg}x\|jD]Q}t|tj�rEt||�|j|�q||�r|j|�qqW||_dS(s>Recursively filter test cases in a suite based on a predicate.N(t_testsRiRGt	TestSuitet
_filter_suiteR\(tsuitetpredtnewtestsR�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s
cCs�tr'tjtjdddt�}n	t�}|j|�}|jr\|j	r\t
�n|j�s�t|j
�dkr�|jr�|j
dd}nLt|j�dkr�|j
r�|jdd}nd}ts�|d7}nt|��ndS(	s2Run tests from a unittest.TestSuite-derived class.t	verbosityitfailfastiismultiple errors occurreds!; run in verbose mode for detailsN(RRGtTextTestRunnerRNRsRR+RttestsRuntskippedRt
wasSuccessfulR�terrorstfailuresR(RtrunnerR�R|((s-/usr/lib64/python2.7/test/support/__init__.pyt
_run_suites 		
cCs$tdkrtSt|j��SdS(N(t_match_test_funcRYRVtid(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
match_test#scCsd|kotjd|�S(NRMs[?*\[\]](Rstsearch(tpattern((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_full_match_test+scs�|tkrdS|s%d}d}nittt|��rLt|�j}nBdjttj	|��}t
j|�j��fd�}|}t
|�a|adS(Nt|cs0�|�rtStt�|jd���SdS(NRM(RVtanyR�R�(ttest_id(tregex_match(s-/usr/lib64/python2.7/test/support/__init__.pytmatch_test_regexJs((t_match_test_patternsRYtallR�R&R�t__contains__R�tfnmatcht	translateRsRHRtR�R!(tpatternsRztregexR+((R*s-/usr/lib64/python2.7/test/support/__init__.pytset_match_tests5s	cGs�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wt|t�t
|�dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN(RGRtTestCaseRiRIRNROtaddTestt
findTestCasesR�t	makeSuiteRR#R (tclassestvalid_typesRtcls((s-/usr/lib64/python2.7/test/support/__init__.pyR,]s
 
Rtwin32tWITH_DOC_STRINGSstest requires docstringscCs�ddl}|dkr!t}nd}tj}t�t_z>|j|d|�\}}|rytd||f��nWd|t_Xtr�d|j|fGHn||fS(s
Run doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    test.support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    i����NRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures(	tdoctestRYRRNRsR	ttestmodRR<(ReRR=tsave_stdoutRR�((s-/usr/lib64/python2.7/test/support/__init__.pyR-|s		
cCstrtj�fSdSdS(Ni(i(tthreadt_count(((s-/usr/lib64/python2.7/test/support/__init__.pyR.�s
cCsTts
dSd}x=t|�D]/}tj�}||kr?Pntjd�qWdS(Ni
g�������?(R@RRAR�R�(t
nb_threadst
_MAX_COUNTtcountR�((s-/usr/lib64/python2.7/test/support/__init__.pyR/�scs,ts
�Stj���fd��}|S(s�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    cs)t�}z�|�SWdt|�XdS(N(R.R/(R{tkey(Rz(s-/usr/lib64/python2.7/test/support/__init__.pyR��s	(R@R�R�(RzR�((Rzs-/usr/lib64/python2.7/test/support/__init__.pyR0�sgN@ccs�tj�}z	dVWdtj�}||}x�tr�tj�}||krSPntj�|kr�tj�|}d|||||f}t|��ntjd�t�q1WXdS(sE
    bpo-31234: Context manager to wait until all threads created in the with
    statement exit.

    Use thread.count() to check if threads exited. Indirectly, wait until
    threads exit the internal t_bootstrap() C function of the thread module.

    threading_setup() and threading_cleanup() are designed to emit a warning
    if a test leaves running threads in the background. This context manager
    is designed to cleanup threads started by the thread.start_new_thread()
    which doesn't allow to wait for thread exit, whereas thread.Thread has a
    join() method.
    NsYwait_threads() failed to cleanup %s threads after %.1f seconds (count: %s, old count: %s)g{�G�z�?(R@RAR�RVRxR�R�(R�t	old_countt
start_timetdeadlineRDtdtRL((s-/usr/lib64/python2.7/test/support/__init__.pytwait_threads_exit�s 	
	
cCscttd�r_d}xGtr[y/tj|tj�\}}|dkrLPnWqPqXqWndS(s�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    twaitpidi����iN(R�RuRVRKtWNOHANG(tany_processR+tstatus((s-/usr/lib64/python2.7/test/support/__init__.pyR7�s		c	cs�t|�}g}zfy,x%|D]}|j�|j|�qWWn.trkdt|�t|�fGHn�nXdVWd|r�|�ntj�}}x�tdd�D]�}|d7}x.|D]&}|jt|tj�d��q�Wg|D]}|j	�r�|^q�}|sPntr�dt|�|fGHq�q�WXg|D]}|j	�rE|^qE}|r�t
dt|���ndS(Ns/Can't start %d threads, only %d threads startediii<g{�G�z�?s7Unable to join %d threads during a period of %d minutessUnable to join %d threads(RQtstartR\RR�R�RR�R�tisAliveRx(tthreadstunlocktstartedR�tendtimet	starttimeR�((s-/usr/lib64/python2.7/test/support/__init__.pyR1s:

	


$%%ccs�t||�rNt||�}t|||�z	|VWdt|||�Xn<t|||�z	dVWdt||�r�t||�nXdS(s�Temporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N(R�RgR�tdelattr(RpRftnew_valtreal_val((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_attr)s		ccsk||kr:||}|||<z	|VWd|||<Xn-|||<z	dVWd||krf||=nXdS(s�Temporary swap out an item with a new object.

    Usage:
        with swap_item(obj, "item", 5):
            ...

        This will set obj["item"] to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `item` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.

        The old value (or None if it doesn't exist) will be assigned to the
        target of the "as" clause, if there is one.
    N((RptitemRWRX((s-/usr/lib64/python2.7/test/support/__init__.pyt	swap_itemHs

	
	cCs\y|j�SWnGtk
rWydjd�|D��SWqXtk
rSt|�SXnXdS(sZEmulate the py3k bytes() constructor.

    NOTE: This is only a best effort function.
    R�css|]}t|�VqdS(N(tchr(t.0R((s-/usr/lib64/python2.7/test/support/__init__.pys	<genexpr>rsN(ttobytesRhR�t	TypeErrortbytes(tb((s-/usr/lib64/python2.7/test/support/__init__.pyR5gs

t	getcountss-types are immortal if COUNT_ALLOCS is definedcCsddl}|j�S(sZReturn a list of command-line arguments reproducing the current
    settings in sys.flags.i����N(t
subprocesst_args_from_interpreter_flags(Rc((s-/usr/lib64/python2.7/test/support/__init__.pytargs_from_interpreter_flagsyscCstjdd|�j�}|S(s�Strip the stderr of a Python process from potential debug output
    emitted by the interpreter.

    This will typically be run on the result of the communicate() method
    of a subprocess.Popen object.
    s\[\d+ refs\]\r?\n?$R�(Rstsubtstrip(R�((s-/usr/lib64/python2.7/test/support/__init__.pyR8scsid|f��fd��Y}tg�|||���|jtt��t�|j�d�dS(NtAcseZ��fd�ZRS(cs0t�d<yt��Wntk
r+nXdS(Ni(RVtnextt
StopIteration(Ra(tdonetit(s-/usr/lib64/python2.7/test/support/__init__.pyt__del__�s


(R<R=Rm((RkRl(s-/usr/lib64/python2.7/test/support/__init__.pyRh�si(RXtassertRaisesRjRiR�t
assertTrue(R�titerR:R{Rh((RkRls-/usr/lib64/python2.7/test/support/__init__.pytcheck_free_after_iterating�s	ccs:tj�}tj�z	dVWd|r5tj�nXdS(N(R�t	isenabledtdisabletenable(thave_gc((s-/usr/lib64/python2.7/test/support/__init__.pyt
disable_gc�s
	cCsTtjd�pd}d}x,|j�D]}|jd�r(|}q(q(W|dkS(s,Find if Python was built with optimizations.t	PY_CFLAGSR�s-Os-O0s-Og(R�s-O0s-Og(t	sysconfigtget_config_varR�RR(tcflagst	final_opttopt((s-/usr/lib64/python2.7/test/support/__init__.pytpython_is_optimized�s
cBs,eZdZdZdZd�Zd�ZRS(s�Try to prevent a crash report from popping up.

    On Windows, don't display the Windows Error Reporting dialog.  On UNIX,
    disable the creation of coredump file.
    cCstjjd�r�ddl}|jj|_d}|jj|�|_|jj|j|B�yddl	}|j
Wnttfk
r�qXi|_
x|j|j|jgD]C}|j
||j�}|j||j�}||f|j
|<q�Wnyddl}Wntk
r%d}nX|dk	r�y9|j|j�|_|j|jd|jdf�Wq�ttfk
r�q�Xntjdkrddl}dd	d
dg}	|j|	d|jd
|j�}
|
j�d}|j�dkrtj j!d�tj j"�qn|S(s�On Windows, disable Windows Error Reporting dialogs using
        SetErrorMode.

        On UNIX, try to save the previous core file size limit, then set
        soft limit to 0.
        R~i����NiiiR�s/usr/bin/defaultsRZscom.apple.CrashReportert
DialogTypeRsR�t	developers:this test triggers the Crash Reporter, that is intentional(#RNR�RRR�R�tkernel32t_k32tSetErrorModet	old_valueR�tCrtSetReportModeRhRFt	old_modestCRT_WARNt	CRT_ERRORt
CRT_ASSERTtCRTDBG_MODE_FILEtCrtSetReportFiletCRTDBG_FILE_STDERRR�RYt	getrlimittRLIMIT_COREt	setrlimitR�R�RctPopentPIPEtcommunicateRgRsR[tflush(RaR�tSEM_NOGPFAULTERRORBOXR�treport_typetold_modetold_fileR�RctcmdtprocRs((s-/usr/lib64/python2.7/test/support/__init__.pyR��sV				

	cGs�|jdkrdStjjd�r�|jj|j�|jr�ddl}xF|jj	�D]2\}\}}|j
||�|j||�q]Wq�n@ddl}y|j
|j|j�Wnttfk
r�nXdS(sARestore Windows ErrorMode or core file behavior to initial value.NR~i����(R�RYRNR�RRR�R�R�R�R]R�R�R�R�R�R�R�(RaR�R�R�R�R�R�((s-/usr/lib64/python2.7/test/support/__init__.pyR�s	"N(R<R=R>RYR�R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR;�s
	GcCs*ddl}t��|j�WdQXdS(s�Deliberate crash of Python.

    Python can be killed by a segmentation fault (SIGSEGV), a bus error
    (SIGBUS), or a different error depending on the platform.

    Use SuppressCrashReport() to prevent a crash report from popping up.
    i����N(R�R;t
_read_null(R�((s-/usr/lib64/python2.7/test/support/__init__.pyt
_crash_pythons	
c
Cs�tjjd�rdy!tjd�}t|�dSWqdtk
r`}|jtjkra�qaqdXnd}t	td�r�ytj
d�}Wq�tk
r�q�Xnd
}tjdkr+yd	d
l}|j
Wnttfk
r�q+Xi}x9|j|j|jfD]}|j
|d�||<qWnzyd}xlt|�D]^}ytj|�}Wn+tk
r�}	|	jtjkr��q�qAXtj|�|d7}qAWWd
|d
k	r�x7|j|j|jfD]}|j
|||�q�WnX|S(
s/Count the number of open file descriptors.
    tlinuxtfreebsds
/proc/self/fdiitsysconftSC_OPEN_MAXR;i����Ni(R�R�(RNR�RRRuR�R�R�R�R�R�R�RYtmsvcrtR�RhRFR�R�R�RtduptEBADFR�(
tnamesR�tMAXFDR�R�R�RDtfdtfd2R�((s-/usr/lib64/python2.7/test/support/__init__.pytfd_count#sR

	

	tSaveSignalscBs)eZdZd�Zd�Zd�ZRS(s�
    Save an restore signal handlers.

    This class is only able to save/restore signal handlers registered
    by the Python signal module: see bpo-13285 for "external" signal
    handlers.
    cCs�ddl}||_ttd|j��|_xHdD]@}yt||�}Wntk
rfq7nX|jj|�q7Wi|_dS(Ni����itSIGKILLtSIGSTOP(R�R�(	tsignalRQRtNSIGtsignalsRgRhRwthandlers(RaR�tsignametsignum((s-/usr/lib64/python2.7/test/support/__init__.pyRchs	

cCsIxB|jD]7}|jj|�}|dkr4q
n||j|<q
WdS(N(R�R�t	getsignalRYR�(RaR�thandler((s-/usr/lib64/python2.7/test/support/__init__.pytsaveus
cCs7x0|jj�D]\}}|jj||�qWdS(N(R�R]R�(RaR�R�((s-/usr/lib64/python2.7/test/support/__init__.pytrestore�s(R<R=R>RcR�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyR�_s	
	((ii@i@i@ii(i@ii(((((�R>R<RFt
contextlibR�R/R�R�R�RwRNRuR�R�R@RGREtUserDictRsR�R�RxRjR@RYt__all__t
SHORT_TIMEOUTR�RRRRHRtcontextmanagerRVRDRXRRUR[R6R4RRRR�RRrRR	R
R}RRR�R�R�R�RR�RR
R�RRRRRR�R�RRRR9R
RRt
PIPE_MAX_SIZEt
SOCK_MAX_SIZERRRt	NameErrort
skipUnlesstrequires_unicodeRtFS_NONASCIItunichrt	characterR$R%tdecodetUnicodeErrorRJRRitTESTFN_UNICODEtTESTFN_ENCODINGR�RtTESTFN_UNENCODABLEtevalR&R�R(t
TEST_HTTP_URLR-RR,R0RRyR�tabspatht__file__tTEST_SUPPORT_DIRR6R�RXRRRDRRtobjectR^R�RR R!t	DictMixinR"R�R%R&R#R$R�R�R�R�R�R�R�R�R�R�R'R:R�R�R�t_4GR�R�R(R)RR*R+RRR2RR	R3RR R!R,R#R&R3R,RytHAVE_DOCSTRINGStrequires_docstringsR-tenvironment_alteredR.R/R0RJR7R1RYR[R5tskipIftrequires_type_collectingReR8RqRvR}R;R�R�R�(((s-/usr/lib64/python2.7/test/support/__init__.pyt<module>s�

								
	
	
&					
!										J			<$			
	


												

				
	.			*' /D					

				$	"


		'				
	
					
	(			&
			#	 					
e		<

Hacked By AnonymousFox1.0, Coded By AnonymousFox