D[c7@sdZedkr!ednddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZyddlZWnek rdZnXddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d2d3d9g7Zdefd:YZdefd;YZde jfd<YZejed=Zed>Z d?Z!d@Z"ddedAZ#dBZ$dCZ%dZ&dDa'dDa(da)dEZ*dFZ+dGZ,ej j-dHredIZ.dJZ/dKZ0dLZ1ne j2Z/e j3Z0e j4Z1dMZ2dNZ3dOZ4dPZ5ej j-dHr?ddl6Z6ddl7Z6dQZ8n dRZ8dSZ9ddTZ:dUZ;dVZ<ej=ej>dWZ?e;dXZ@dYZAdZZBdZCdZDyeEeZFWneGk reZFnXej j-d^ZHdZIeFrxeJd_eJd`eJdaeJdbeJdceJddeJdeeJdfeJdgeJdheJdif D]GZKy&eKjLejMjNejMWneOk rqUXeKZIPqUWne jPd^krdjZQne jPdkkrdlZQndmZQeFr~eRdneErdoZSneEdodpZSejMZTeUedq s8ejVdrdskrAdZWq~eXdtZWyeWjLduWneYk rqq~XdveWGHndwjZeQe j[ZQe j\Z]ejdxedyZ^e_ddzZ`d{Zad|Zbd}Zcdd~ZddeefdYZfedZgejdZhejdZid$eefdYZjd%ejkfdYZldeefdYZmd(eefdYZnejdddZoejdZpdZqdZrdZsdZtdZueUedrdeuZuneudZvdZwdZxdZydZzdZ{dZ|dZ}d\e}Z~dse~Zd[e~ZejZdZde}dZde}edZdZd.ddYZdZdZdZddZdZdZdZdZedep%ej dkp%ejdZe jedZddZdZdZdZdZejdZdZdZdZdS(s7Supporting definitions for the Python regression tests.stest.test_supports3test_support must be imported from the test packageiNtErrort TestFailedtResourceDeniedt import_moduletverboset use_resourcest max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestfind_unused_portt bind_porttfcmpt have_unicodet is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningst CleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localet set_memlimitt bigmemtesttbigaddrspacetesttBasicTestRunnert run_unittestt run_doctesttthreading_setuptthreading_cleanupt reap_childrent cpython_onlytcheck_impl_detailt get_attributet py3k_bytestimport_fresh_moduletstrip_python_stderrcBseZdZRS(s*Base class for regression test exceptions.(t__name__t __module__t__doc__(((s'/usr/lib/python2.7/test/test_support.pyR,scBseZdZRS(s Test failed.(R5R6R7(((s'/usr/lib/python2.7/test/test_support.pyR/scBseZdZRS(sTest 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. (R5R6R7(((s'/usr/lib/python2.7/test/test_support.pyR2sccs=|r4tjtjddtdVWdQXndVdS(sContext 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(R8((s'/usr/lib/python2.7/test/test_support.pyt_ignore_deprecated_imports:s   c CsSt|Aytj|SWn(tk rH}tjt|nXWdQXdS(sImport 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(R=t importlibRt ImportErrortunittesttSkipTesttstr(tnamet deprecatedtmsg((s'/usr/lib/python2.7/test/test_support.pyRIs  cCs|tjkr&t|tj|=nxTttjD]C}||ks[|j|dr6tj|||RR?RRtitemsRGRH( RCtfreshtblockedRDRLtnames_to_removet fresh_namet blocked_namet fresh_modulet orig_nametmoduletname_to_remove((s'/usr/lib/python2.7/test/test_support.pyR3ps&      cCsKyt||}Wn-tk rBtjd|j|fnX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %s has no attribute %sN(tgetattrtAttributeErrorR@RAR5(tobjRCt attribute((s'/usr/lib/python2.7/test/test_support.pyR1s   iicCs |adS(N(t_original_stdout(tstdout((s'/usr/lib/python2.7/test/test_support.pyRscCs tp tjS(N(RdRGRe(((s'/usr/lib/python2.7/test/test_support.pyRscCs&ytj|=Wntk r!nXdS(N(RGRHRP(RC((s'/usr/lib/python2.7/test/test_support.pyR s twincCs|||r|}n$tjj|\}}|p:d}d}xR|dkrtj|}|rm|n ||ks}dStj||d9}qFWtjd|tdddS(NRFgMbP?g?is)tests may fail, delete still pending for t stackleveli( tostpathtsplittlistdirttimetsleepR9twarntRuntimeWarning(tfunctpathnametwaitalltdirnameRCttimeouttL((s'/usr/lib/python2.7/test/test_support.pyt_waitfors     cCsttj|dS(N(RvRhR (tfilename((s'/usr/lib/python2.7/test/test_support.pyt_unlinkscCsttj|dS(N(RvRhtrmdir(Rs((s'/usr/lib/python2.7/test/test_support.pyt_rmdirscs6fdt|dtttj|dS(Ncsuxntj|D]]}tjj||}tjj|r`t|dttj|qtj|qWdS(NRr( RhRkRitjointisdirRvRORyR (RiRCtfullname(t _rmtree_inner(s'/usr/lib/python2.7/test/test_support.pyR~s Rr(RvRORhRy(Ri((R~s'/usr/lib/python2.7/test/test_support.pyt_rmtreescCs&yt|Wntk r!nXdS(N(RxtOSError(Rw((s'/usr/lib/python2.7/test/test_support.pyR s cCs@yt|Wn+tk r;}|jtjkr<q<nXdS(N(RzRterrnotENOENT(Rsterror((s'/usr/lib/python2.7/test/test_support.pyRys cCsIyt|Wn4tk rD}|jtjtjfkrEqEnXdS(N(RRRRtESRCH(Rite((s'/usr/lib/python2.7/test/test_support.pyR s cCsjt|xYtjD]N}ttjj||tjdttjj||tjdqWdS(sm"Forget" a module was ever imported by removing it from sys.modules and deleting any .pyc and .pyo files.tpyctpyoN(R RGRiR RhR{textsep(RMRs((s'/usr/lib/python2.7/test/test_support.pyR s $cCsd}d}dtjfdY}tjj}|j}|sRtjn|}tjj}|j||tj |tj |tj |}|stjnt |j |@S(NitUSEROBJECTFLAGScBs;eZdejjfdejjfdejjfgZRS(tfInheritt fReservedtdwFlags(R5R6tctypestwintypestBOOLtDWORDt_fields_(((s'/usr/lib/python2.7/test/test_support.pyRs( Rt Structuretwindlltuser32tGetProcessWindowStationtWinErrorRRtGetUserObjectInformationWtbyreftsizeoftboolR(t UOI_FLAGSt WSF_VISIBLERtdllthtuoftneededtres((s'/usr/lib/python2.7/test/test_support.pyt_is_gui_availables"      cCstS(N(RO(((s'/usr/lib/python2.7/test/test_support.pyR,scCstdk o|tkS(sPTest whether a resource is enabled. Known resources are set by regrtest.py.N(RRR(tresource((s'/usr/lib/python2.7/test/test_support.pyR /scCs|dkr(t r(tjdntjdjjddkrMdSt|s|dkrrd|}nt |ndS(sRaise ResourceDenied if the specified resource is not available. If the caller's module is __main__ then automatically return True. The possibility of False being returned occurs when regrtest.py is executing.tguisCannot use the 'gui' resourceiR5t__main__Ns$Use of the `%s' resource not enabled( RR@RARGt _getframet f_globalstgetR RRR(RRE((s'/usr/lib/python2.7/test/test_support.pyR4s!   s 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/lib/python2.7/test/test_support.pyRKs 6  cCs|jtjkr|jtjkrttdrc|jtjtjdkrct dqcnttdry1|jtjtj dkrt dnWqt k rqXnttdr|j tjtj dqn|j|df|jd}|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(RRtAF_INETttypet SOCK_STREAMthasattrt getsockoptt SOL_SOCKETRRRtEnvironmentErrort setsockoptRtbindt getsockname(tsockthostR((s'/usr/lib/python2.7/test/test_support.pyRs$ gư>cCs#t|tst|trcy8t|t|t}t|||krUdSWqqXnt|t|krt|ttfrxPttt |t |D]-}t ||||}|dkr|SqWt |t |kt |t |kS||k||kS(Ni( t isinstancetfloattabsRRttupleRJtrangetmintlenR(txtytfuzztitoutcome((s'/usr/lib/python2.7/test/test_support.pyRs-( ,iiitjavaii0iAiiii i*iii s$testtriscosttestfiles@testts@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 {}_{}_tmpttempcwdccs trct|trcy|jtjp-d}Wqctk r_|s`tjdq`qcXnt j }t }y$t j |t j |t}Wn7tk r|sntjd|tddnXzt j VWdt j ||rt|nXdS(sR Context manager that creates a temporary directory and set it as CWD. The new CWD is created in the current directory and it's named *name*. If *quiet* is False (default) and it's not possible to create or change the CWD, an error is raised. If it's True, only a warning is raised and the original CWD is used. tasciis;unable to encode the cwd name with the filesystem encoding.s,tests may fail, unable to change the CWD to RgiN(RRtunicodetencodeRGtgetfilesystemencodingtUnicodeEncodeErrorR@RARhtgetcwdRQtmkdirtchdirRORR9RnRoR (RCtquiett saved_dirt is_temporary((s'/usr/lib/python2.7/test/test_support.pyR8s,         cCstjj|r|S|dk r:tjj||}ntj}tjj|g|}x9|D]1}tjj||}tjj|rc|SqcW|S(sTry 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(RhRitisabsRRR{RGRstexists(tfiletheretsubdirRitdntfn((s'/usr/lib/python2.7/test/test_support.pyR\s   cCsJ|j}|jg|D]}d|^q}dj|}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(RVtsortR{(tdictRVtpairt reprpairst withcommas((s'/usr/lib/python2.7/test/test_support.pyRks   cCs9ttd}z|jSWd|jttXdS(s` Create an invalid file descriptor by opening and closing a file and return its fd. twbN(topenRtfilenoRR (R((s'/usr/lib/python2.7/test/test_support.pyt make_bad_fdss  cCs|jtt|dddS(Ns texec(t assertRaisest SyntaxErrortcompile(ttestcaset statement((s'/usr/lib/python2.7/test/test_support.pyRsc sbddl}ddl}|j|djdd}tjjtjjtd|}fd}tjj|r||}|dk r|St |nt dt d|IJ|j |dd }zNt|d 9}|j} x#| r|j| |j} qWWdQXWd|jX||}|dk rN|Std |dS( Niit/tdatacsGt|}dkr|S|r9|jd|S|jdS(Ni(RRRtseekR(Rtf(tcheck(s'/usr/lib/python2.7/test/test_support.pytcheck_valid_files    turlfetchs fetching %s ...RtiRsinvalid resource "%s"(turlparseturllib2RjRhRiR{Rst__file__RRRR RRturlopenRtreadtwriteRR( turlRRRRwRRRtoutts((Rs'/usr/lib/python2.7/test/test_support.pyRs. $           tWarningsRecordercBs8eZdZdZdZedZdZRS(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/lib/python2.7/test/test_support.pyt__init__s cCs\t|j|jkr,t|jd|S|tjjkrBdStd||fdS(Nis%r has no attribute %r( RRRR`R9tWarningMessaget_WARNING_DETAILSRRRa(Rtattr((s'/usr/lib/python2.7/test/test_support.pyt __getattr__s cCs|j|jS(N(RR(R((s'/usr/lib/python2.7/test/test_support.pyR9scCst|j|_dS(N(RRR(R((s'/usr/lib/python2.7/test/test_support.pytresets(R5R6R7RR tpropertyR9R (((s'/usr/lib/python2.7/test/test_support.pyRs   c csptjd}|jjd}|r4|jntjdt&}tjdj dt |VWdQXg|D]}|j ^qu}g}x|D]\}} t } x[|D]R} t | } tj|| tjrt| j| rt} |j| qqW| r| r|j|| jfqqW|rOtd|dn|rltd |dndS( sCatch 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__trecordR9talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RGRRRtclearR9R:RORHt simplefilterRtmessageRQRBtretmatchtIt issubclasst __class__tremoveRUR5tAssertionError( tfiltersRtframetregistrytwtwarningtreraisetmissingREtcattseentexcR((s'/usr/lib/python2.7/test/test_support.pyt_filterwarningss0  cOsI|jd}|s<dtff}|dkr<t}q<nt||S(sContext 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) RRN(RtWarningRRROR%(RtkwargsR((s'/usr/lib/python2.7/test/test_support.pyRs   cOs@tjr$|s*dtff}q*nd}t||jdS(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) RR((RGt py3kwarningR<R%R(RR'((s'/usr/lib/python2.7/test/test_support.pyRs  cBs)eZdZdZdZdZRS(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(RGRHtcopytoriginal_modulesR5(Rt module_namest module_nameR^((s'/usr/lib/python2.7/test/test_support.pyR&s  cCs|S(N((R((s'/usr/lib/python2.7/test/test_support.pyt __enter__3scGstjj|jdS(N(RGRHtupdateR*(Rt ignore_exc((s'/usr/lib/python2.7/test/test_support.pyt__exit__6s(R5R6R7RR-R0(((s'/usr/lib/python2.7/test/test_support.pyRs  cBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS(N(Rhtenviront_environt_changed(R((s'/usr/lib/python2.7/test/test_support.pyR?s cCs |j|S(N(R2(Rtenvvar((s'/usr/lib/python2.7/test/test_support.pyt __getitem__CscCs<||jkr+|jj||j|is   cBs2eZdZdZdZddddZRS(sRaise 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(RR$R'((s'/usr/lib/python2.7/test/test_support.pyRs cCs|S(N((R((s'/usr/lib/python2.7/test/test_support.pyR-scCs}|dk ryt|j|ryxX|jjD]8\}}t||sMPnt|||kr.Pq.q.WtdndS(sIf 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(RRRR$RCt iteritemsRR`R(Rttype_R6t tracebackR t attr_value((s'/usr/lib/python2.7/test/test_support.pyR0sN(R5R6R7RR-RRR0(((s'/usr/lib/python2.7/test/test_support.pyR#s  g>@c #sdddddg}d d!d"d#d$g}td||gsg|D]\}}tt||^qSg|D]\}}tt||^q~nfd}tj}zy%|dk rtj|ndVWntk r} xxtrz| j } t | dkrDt | dtrD| d} qt | dkrvt | dtrv| d} qPqW|| nXWdtj|XdS(%sReturn a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.t ECONNREFUSEDiot ECONNRESETiht EHOSTUNREACHiqt ENETUNREACHiet ETIMEDOUTint EAI_AGAINitEAI_FAILit EAI_NONAMEit EAI_NODATAit WSANO_DATAi*sResource '%s' is not availablecst|dd}t|tjsNt|tjrB|ksN|kr{tsrtjj j ddnndS(NRis ( R`RRRRRttgaierrorRRGtstderrRtargs(terrtn(tcaptured_errnostdeniedt gai_errnos(s'/usr/lib/python2.7/test/test_support.pyt filter_errors Niii(RHio(RIih(RJiq(RKie(RLin(RMi(RNi(ROi(RPi(RQi*( RR`RRtgetdefaulttimeoutRRtsetdefaulttimeouttIOErrorRORTRR( t resource_nameRtterrnostdefault_errnostdefault_gai_errnosRCtnumRZt old_timeoutRUta((RWRXRYs'/usr/lib/python2.7/test/test_support.pyR$sH  (+     % %   ccs[ddl}tt|}tt||jztt|VWdtt||XdS(sReturn a context manager used by captured_stdout and captured_stdin that temporarily replaces the sys stream *stream_name* with a StringIO.iN(tStringIOR`RGtsetattr(t stream_nameRet orig_stdout((s'/usr/lib/python2.7/test/test_support.pyR!s  cCs tdS(sCapture the output of sys.stdout: with captured_stdout() as s: print "hello" self.assertEqual(s.getvalue(), "hello") Re(R!(((s'/usr/lib/python2.7/test/test_support.pyR"scCs tdS(NRS(R!(((s'/usr/lib/python2.7/test/test_support.pytcaptured_stderrscCs tdS(Ntstdin(R!(((s'/usr/lib/python2.7/test/test_support.pytcaptured_stdinscCs8tjtr tjdntjtjdS(sForce 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(tgctcollectRRlRm(((s'/usr/lib/python2.7/test/test_support.pyt gc_collects  t2PtgettotalrefcounttPcCstjt|dS(Nt0P(tstructtcalcsizet_header(tfmt((s'/usr/lib/python2.7/test/test_support.pyt calcobjsizescCstjt|dS(NRr(RsRtt_vheader(Rv((s'/usr/lib/python2.7/test/test_support.pyt calcvobjsizesii cCsddl}tj|}t|tkr:|jt@s_t|tkrot|jt@ro||j7}ndt|||f}|j|||dS(Nis&wrong size for %s: got %d, expected %d( t _testcapiRGt getsizeofRt __flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADt assertEqual(ttesttotsizeRztresultRE((s'/usr/lib/python2.7/test/test_support.pyt check_sizeofs %csfd}|S(Ncs1fd}j|_j|_|S(Ncsy.ddl}t|}|j|}Wn$tk rDnAd}}n1Xx-D]%}y|j||PWq\q\Xq\Wz||SWd|r|r|j||nXdS(Ni(tlocaleR`t setlocaleRaRR(RTtkwdsRtcategoryt orig_localetloc(tcatstrRptlocales(s'/usr/lib/python2.7/test/test_support.pytinner+s$    (t func_nameR7(RpR(RR(Rps'/usr/lib/python2.7/test/test_support.pyt decorator*s  ((RRR((RRs'/usr/lib/python2.7/test/test_support.pyR%)scCsidd6td6td6dtd6}tjd|tjtjB}|dkrgtd|fntt |j d||j d j }|a |t krt }n|tdkrtd |fn|adS( NiR<tmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRRt IGNORECASEtVERBOSERRt ValueErrortintRtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesRtmemlimit((s'/usr/lib/python2.7/test/test_support.pyR&Us   2  icsfd}|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. cs7fd}|_|_|_|S(Ncsts.d}|j|dtkn^tt}|krutrqtjjdjfndSt |dt}||S(Niis)Skipping %s because of memory constraint i2( Rt assertFalseRRRRGRSRR5tmax(Rtmaxsize(Rtmemusetminsizetoverhead(s'/usr/lib/python2.7/test/test_support.pytwrapperxs"  (RRR(RR(RRR(Rs'/usr/lib/python2.7/test/test_support.pyRws    ((RRRR((RRRs'/usr/lib/python2.7/test/test_support.pyR'js csfd}|S(Ncs7fd}|_|_|_|S(Ncsftsd}n}ts" rYt|krYtrUtjjdjfndS||S(Nis)Skipping %s because of memory constraint (RRRGRSRR5(RR(tdry_runRRR(s'/usr/lib/python2.7/test/test_support.pyRs   (RRR(RR(RRRR(Rs'/usr/lib/python2.7/test/test_support.pyRs    ((RRRRR((RRRRs'/usr/lib/python2.7/test/test_support.pytprecisionbigmemtestscsfd}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjdjfq<n |SdS(Ns)Skipping %s because of memory constraint (RRRRGRSRR5(R(R(s'/usr/lib/python2.7/test/test_support.pyRs   ((RR((Rs'/usr/lib/python2.7/test/test_support.pyR(scBseZdZRS(cCstj}|||S(N(R@t TestResult(RRR((s'/usr/lib/python2.7/test/test_support.pytruns  (R5R6R(((s'/usr/lib/python2.7/test/test_support.pyR)scCs|S(N((Rb((s'/usr/lib/python2.7/test/test_support.pyt_idscCsM|dkr#t r#tjdSt|r3tStjdj|SdS(NRsresource 'gui' is not availablesresource {0!r} is not enabled(RR@tskipR Rtformat(R((s'/usr/lib/python2.7/test/test_support.pytrequires_resources   cCstdt|S(s9 Decorator for tests only applicable on CPython. tcpython(t impl_detailRO(R((s'/usr/lib/python2.7/test/test_support.pyR/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 ( R0RRRt _parse_guardstsortedR9RR{R@R(REtguardst guardnamestdefault((s'/usr/lib/python2.7/test/test_support.pyRs   cCsW|sitd6tfS|jd}|j|gt|ksLt|| fS(NRi(RORQtvaluesRR(Rtis_true((s'/usr/lib/python2.7/test/test_support.pyRs %cKs.t|\}}|jtjj|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 (RRtplatformtpython_implementationR(RR((s'/usr/lib/python2.7/test/test_support.pyR0scCstr!tjtjdd}n t}|j|}|jst|j dkrx|j rx|j dd}nLt|j dkr|j r|j dd}nd}ts|d7}nt |ndS(s2Run tests from a unittest.TestSuite-derived class.t verbosityiiismultiple errors occurreds!; run in verbose mode for detailsN( RR@tTextTestRunnerRGReR)Rt wasSuccessfulRterrorstfailuresR(tsuitetrunnerRRU((s'/usr/lib/python2.7/test/test_support.pyt _run_suites   cGstjtjf}tj}x|D]}t|trx|tjkri|jtjtj|qt dq%t||r|j|q%|jtj |q%Wt |dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN( R@t TestSuitetTestCaseRRBRGRHtaddTestt findTestCasesRt makeSuiteR(tclassest valid_typesRtcls((s'/usr/lib/python2.7/test/test_support.pyR*s   Rtwin32tWITH_DOC_STRINGSstest requires docstringscCsddl}|dkr!t}nd}tj}tt_z>|j|d|\}}|rytd||fnWd|t_Xtrd|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). iNRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures( tdoctestRRRRGReRttestmodRR5(R^RRt save_stdoutRR((s'/usr/lib/python2.7/test/test_support.pyR+!s      cCstrtjfSdSdS(Ni(i(tthreadt_count(((s'/usr/lib/python2.7/test/test_support.pyR,Is cCsTts dSd}x=t|D]/}tj}||kr?PntjdqWdS(Ni g?(RRRRlRm(t nb_threadst _MAX_COUNTtcountRV((s'/usr/lib/python2.7/test/test_support.pyR-Os  cs,ts Stjfd}|S(sUse 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-(RTtkey(Rp(s'/usr/lib/python2.7/test/test_support.pyRcs (Rt functoolstwraps(RpR((Rps'/usr/lib/python2.7/test/test_support.pyt reap_threads[scCscttdr_d}xGtr[y/tj|tj\}}|dkrLPnWqPqXqWndS(sUse 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. twaitpidiiN(RRhRORtWNOHANG(t any_processtpidtstatus((s'/usr/lib/python2.7/test/test_support.pyR.ls   ccs|t||rNt||}t|||z dVWdt|||Xn*t|||z dVWdt||XdS(smTemporary 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. N(RR`Rftdelattr(RbR tnew_valtreal_val((s'/usr/lib/python2.7/test/test_support.pyt swap_attrs   cCs\y|jSWnGtk rWydjd|DSWqXtk rSt|SXnXdS(sZEmulate the py3k bytes() constructor. NOTE: This is only a best effort function. Rcss|]}t|VqdS(N(tchr(t.0R((s'/usr/lib/python2.7/test/test_support.pys sN(ttobytesRaR{t TypeErrortbytes(tb((s'/usr/lib/python2.7/test/test_support.pyR2s  cCsddl}|jS(sZReturn a list of command-line arguments reproducing the current settings in sys.flags.iN(t subprocesst_args_from_interpreter_flags(R((s'/usr/lib/python2.7/test/test_support.pytargs_from_interpreter_flagss cCstjdd|j}|S(sStrip 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(Rtsubtstrip(RS((s'/usr/lib/python2.7/test/test_support.pyR4s((ii@i@i@ii(i@ii((R7R5R?t contextlibRRRlRRGRhRtshutilR9R@R>tUserDictRRlRst sysconfigRRRt__all__t ExceptionRRRARtcontextmanagerROR=RQRRNRTR3R1RRRRRdRRR RKRvRxRzRR RyR R Rtctypes.wintypesRR RRtHOSTv6RRRRRRt PIPE_MAX_SIZEt SOCK_MAX_SIZERRt NameErrorRt FS_NONASCIItunichrt characterRRtdecodet UnicodeErrorRCRRtTESTFN_UNICODEtTESTFN_ENCODINGRRtTESTFN_UNENCODABLEtevalRRtgetpidRRRRRRRRRtobjectRR%RRRt DictMixinR R>R#R$R!R"RiRkRnRuRxRwRyR~R}RR%RRRt_4GRRR&R'RR(R)RRR/RRR0RR*tget_config_vartHAVE_DOCSTRINGSt skipUnlesstrequires_docstringsR+R,R-RR.RR2RR4(((s'/usr/lib/python2.7/test/test_support.pyts                                 &     !               < $                        #   * ' /A         %     '         (