î g f:ã†@sdZedkr!edƒ‚nddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl Z ddl!Z!Wnek r•dZ dZ!YnXyddl"Z#Wnek rÀdZ#YnXyddl$Z$Wnek rëdZ$YnXyddl%Z%Wnek rdZ%YnXyddl&Z&Wnek rAdZ&YnXyddl'Z'Wnek rldZ'YnXyddl(Z(Wnek r—dZ(YnXddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRgNZ)GdSd „d e*ƒZ+GdTd „d e+ƒZ,GdUd „d ej-ƒZ.ej/dVdWdX„ƒZ0dYdZfd[d „Z1d\d]„Z2d^d_„Z3d`d9„Z4dad:„Z5ffdYdbd„Z6dcd5„Z7ddZ8dZ9da:da;dYZ<dZ=da>ded„Z?dfd„Z@dgd„ZAejjBdhƒrádYdidj„ZCdkdl„ZDdmdn„ZEdodp„ZFnejGZDejHZEejIZFdqd„ZGdrds„ZHdtd„ZIdudv„ZJdwd„ZKdxdy„ZLdzd „ZMdd{d!„ZNd|d}„ZOd~d"„ZPdd#„ZQd€d$„ZRd�ZSd‚ZTejUejVdƒd?„ZWeSd„d@„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£kr*ddlqZqeqjrd¤epƒZpnejsƒZtdZuejgd.kr°ejvƒjd§krþehd¨ZuyeujwetƒWnexk r�Yq­Xeyd©euetfƒdZuqþnNejd£krþydªjzetƒWqþe{k rúehd«jzetd¬ƒZuYqþXndZ|xHd/D]@ZgyegjzetƒWq e{k rJejnehƒegZ|PYq Xq Wekrfehd±ekZ}ndZ}ej~ƒZej/ddYd²d³„ƒZ€ej/dYd´dµ„ƒZ�ej/d¶dYd·d„ƒZ‚eƒed¸ƒríej/d¹dB„ƒZ„nej…j†ej…j‡eˆƒƒZ‰ej…j†e‰ƒZŠej…j‹eŠdºƒZŒdd»d„Z�d¼d„ZŽd½dQ„Z�d¾d¿„Z�dÀd%„Z‘dÁdA„Z’GdÂdÄdÃe“ƒZ”dYdÄdÅ„Z•ej/dÆdI„ƒZ–GdÇd„de“ƒZ—GdÈdJ„dJej˜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¬ne«dáZ­dâdã„Z®dädå„Z¯d0Z°d1Z±dèdé„Z²dêdK„Z³dëdR„Z´d2ZµdŠeµZ¶d§e¶Z·d‰e¶Z¸ej¹ZºdìdO„Z»Gdídî„dîƒZ¼dVdïd2„Z½dðd3„Z¾Gdñd+„d+ƒZ¿dòdó„ZÀdôdõ„ZÁdöd4„ZÂdd÷dø„ZÃdùdú„ZÄdûd<„ZÅdüdý„ZÆdþdÿ„ZÇdd„ZÈdd„ZÉdd,„ZÊdd„ZËeŃo� ejdko� ejÌdƒ ZÍeËjdk o£ eÍ ZÎej^eÎd ƒZÏddd d-„ZÐd d „ZÑd d„ZÒddE„ZÓddF„ZÔddG„ZÕddC„ZÖej/dddH„ƒZ×ej/ddM„ƒZØej/ddL„ƒZÙdd„ZÚdd„ZÛGddD„dDejÜj݃ZÞGddN„dNe“ƒZßdaàdd„Zádd.„Zâdaãdd„Zäd d7„Zåd!d„ZæGd"dP„dPƒZçd#d$„Zèd%d&„ZédS(3z7Supporting definitions for the Python regression tests.z 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Ú 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ÚEnvironmentVarGuardÚrun_with_localeÚ swap_itemÚ swap_attrÚMatcherÚ set_memlimitÚSuppressCrashReportÚsortdictÚ run_with_tzc@seZdZdZdS)rz*Base class for regression test exceptions.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rTrTú:/opt/alt/python34/lib64/python3.4/test/support/__init__.pyrls c@seZdZdZdS)rz Test failed.N)rPrQrRrSrTrTrTrUros c@seZdZdZdS)r zàTest skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not be enabled. It is used to distinguish between expected and unexpected skips. N)rPrQrRrSrTrTrTrUr rs Tc cs=|r4tjƒ�tjddtƒdVWdQXndVdS)zžContext manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect. Úignorez.+ (module|package)N)ÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarning)rVrTrTrUÚ_ignore_deprecated_importszs   r[FÚ required_oncCsƒt|ƒ�qytj|ƒSWnXtk rx}z8tjjt|ƒƒrQ‚ntj t |ƒƒ‚WYdd}~XnXWdQXdS)acImport 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. If a module is required on a platform but optional for others, set required_on to an iterable of platform prefixes which will be compared against sys.platform. N) r[Ú importlibr Ú ImportErrorÚsysÚplatformÚ startswithÚtupleÚunittestÚSkipTestÚstr)ÚnameÚ deprecatedr\ÚmsgrTrTrUr Šs cCs�|tjkr&t|ƒtj|=nxTttjƒD]C}||ks[|j|dƒr6tj|||Àsz$anticipate_failure..)rcZexpectedFailure)Z conditionrTrTrUr6¸scCsn|dkrd}ntjjtjjtjjtƒƒƒ}|jd|d|d|ƒ}|j|ƒ|S)zòGeneric load_tests implementation for simple test packages. Most packages can implement load_tests using this function as follows: def load_tests(*args): return load_package_tests(os.path.dirname(__file__), *args) Nztest*Z start_dirZ top_level_dirÚpattern)ÚosÚpathÚdirnameÚ__file__ZdiscoverZaddTests)Zpkg_dirÚloaderZstandard_testsrtZtop_dirZ package_testsrTrTrUr7Âs      c Csýt|ƒ�ëi}g}t||ƒz€yax|D]}t||ƒq3Wx-|D]%}t||ƒsQ|j|ƒqQqQWtj|ƒ}Wntk r¤d}YnXWdx'|jƒD]\} } | tj | ._rmtree_innerr�T)r’rur•)rvrT)r£rUÚ_rmtreeRsr¤c Cs-yt|ƒWnttfk r(YnXdS)N)r”ÚFileNotFoundErrorÚNotADirectoryError)r“rTrTrUrhsc Cs'yt|ƒWntk r"YnXdS)N)r–r¥)rwrTrTrUr•ns r•c Cs'yt|ƒWntk r"YnXdS)N)r¤r¥)rvrTrTrUrts cCsitjj|ƒ}tjjtjj|ƒƒ}tjj||trKdndƒ}tj ||ƒ|S)alMove a PEP 3147 pyc/pyo file to its legacy pyc/pyo location. The choice of .pyc or .pyo extension is done based on the __debug__ flag value. :param source: The file system path to the source file. The source file does not need to exist, however the PEP 3147 pyc file must exist. :return: The file system path to the legacy pyc file. ÚcÚo) r]ÚutilÚcache_from_sourcerurvrwÚabspathr˜Ú __debug__Úrename)ÚsourceZpyc_fileZup_oneZ legacy_pycrTrTrUÚmake_legacy_pyczs %r¯cCs�t|ƒx~tjD]s}tjj||dƒ}t|dƒt|dƒttjj|ddƒƒttjj|ddƒƒqWdS)z“'Forget' a module was ever imported. This removes the module from sys.modules and deletes any PEP 3147 or legacy .pyc and .pyo files. z.pyr§r¨Údebug_overrideTFN) r r_rvrur˜rr]r©rª)rnrwr®rTrTrUrŠs csÄttdƒrtjSd}tjjdƒr ddl‰ddl‰d}d}G‡fdd†dˆjƒ}ˆj j }|j ƒ}|sžˆj ƒ‚n|ƒ}ˆj jƒ}|j||ˆj|ƒˆj|ƒˆj|ƒƒ}|sˆj ƒ‚nt|j|@ƒsød}qønØtjdkrødd lm} m‰m} m} dd lm} | j| d ƒƒ} | jƒdkr‘d }qøG‡fd d†d| ƒ}|ƒ}| |ƒ}| j|ƒdksì| j|ƒdkrød}qøn|sªy1ddlm}|ƒ}|jƒ|j ƒWqªt!k r¦}zUt"|ƒ}t#|ƒdkry|dd…d}ndj$t%|ƒj&|ƒ}WYdd}~XqªXn|t_'| t_tjS)NÚresultrƒrr€csCeZdZd”jjfd”jjfd”jjfgZdS)z*_is_gui_available..USEROBJECTFLAGSZfInheritZ fReservedÚdwFlagsN)rPrQrRÚwintypesZBOOLÚDWORDÚ_fields_rT)ÚctypesrTrUÚ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..ProcessSerialNumberZ highLongOfPSNZ lowLongOfPSNN)rPrQrRrµrT)rºrTrUÚProcessSerialNumberÈs  r¾z#cannot run without OS X gui process)ÚTké2z [...]zTk unavailable due to {}: {})(ÚhasattrÚ_is_gui_availabler±r_r`rar¶Zctypes.wintypesr¼ÚwindllZuser32ZGetProcessWindowStationZWinErrorr³r´ZGetUserObjectInformationWZbyrefÚsizeofÚboolr²r¹rºr»Z ctypes.utilr½Z LoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterr¿ÚupdateZdestroyÚ ExceptionreÚlenÚformatÚtyperPÚreason)rËZ UOI_FLAGSZ WSF_VISIBLEr·ZdllÚhZuofZneededÚresr¹r»r¼r½Z app_servicesr¾ZpsnZpsn_pr¿ÚrootÚeZ err_stringrT)rºr¶rUr›sf         "         rÂcCstdkp|tkS)zÁ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)r)ÚresourcerTrTrUräscCs`|dkr(tƒ r(ttjƒ‚nt|ƒs\|dkrMd|}nt|ƒ‚ndS)z@Raise ResourceDenied if the specified resource is not available.ÚguiNz"Use of the %r resource not enabled)rÂr rËr)rÐrhrTrTrUrìs    cs‡‡fdd†}|S)zàDecorator raising SkipTest if the OS is `sysname` and the version is less than `min_version`. For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if the FreeBSD version is less than 7.2. cs4tjˆƒ‡‡‡fdd†ƒ}ˆ|_|S)Nc s¸tjƒˆkr«tjƒjddƒd}y"ttt|jdƒƒƒ}Wntk rdYq«X|ˆkr«djtt ˆƒƒ}t j dˆ||fƒ‚q«nˆ||ŽS)Nú-r€rriz(%s version %s or higher required, not %s) r`ÚsystemÚreleaser‡rbÚmapÚintÚ ValueErrorr˜rercrd)ÚargsÚkwÚ version_txtÚversionÚmin_version_txt)r�Ú min_versionÚsysnamerTrUÚwrapperýs"  z:_requires_unix_version..decorator..wrapper)Ú functoolsÚwrapsrÝ)r�rß)rÝrÞ)r�rUÚ decoratorüs' z)_requires_unix_version..decoratorrT)rÞrÝrârT)rÝrÞrUÚ_requires_unix_versionõsrãcGs td|ƒS)zÛDecorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is less than `min_version`. For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD version is less than 7.2. ZFreeBSD)rã)rÝrTrTrUrscGs td|ƒS)zÚDecorator raising SkipTest if the OS is Linux and the Linux version is less than `min_version`. For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux version is less than 2.6.32. ZLinux)rã)rÝrTrTrUr scs‡fdd†}|S)zÐ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. cs1tjˆƒ‡‡fdd†ƒ}ˆ|_|S)Nc s¦tjdkr™tjƒd}y"ttt|jdƒƒƒ}Wntk rUYq™X|ˆkr™djtt ˆƒƒ}t j d||fƒ‚q™nˆ||ŽS)Nr¸rriz&Mac OS X %s or higher required, not %s) r_r`Zmac_verrbrÕrÖr‡r×r˜rercrd)rØrÙrÚrÛrÜ)r�rÝrTrUrß*s"  z4requires_mac_ver..decorator..wrapper)ràrárÝ)r�rß)rÝ)r�rUrâ)s$ z#requires_mac_ver..decoratorrT)rÝrârT)rÝrUr!"sz 127.0.0.1z::1cCs/tj||ƒ}t|ƒ}|jƒ~|S)aî 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 OSError 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. )Úsocketr=Úclose)ÚfamilyZsocktypeZtempsockÚportrTrTrUr<Ds 8  c Cs|jtjkrø|jtjkrøttdƒrc|jtjtjƒdkrct dƒ‚qcnttdƒrÊdt j krÊy1|jtjtj ƒdkr±t dƒ‚nWqÊt k rÆYqÊXnttdƒrø|jtjtjdƒqøn|j|dfƒ|jƒd}|S) a%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. Ú 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ÁZ getsockoptZ SOL_SOCKETrèrruÚenvironrér›Z setsockoptrêÚbindZ getsockname)ÚsockÚhostrçrTrTrUr=‚s $ cCsytjrud}zLy3tjtjtjƒ}|jtdfƒdSWntk rYYnXWd|rq|jƒnXndS)z+Check whether IPv6 is enabled on this host.NrTF)räZhas_ipv6ZAF_INET6rìrîÚHOSTv6r›rå)rïrTrTrUÚ_is_ipv6_enabled¨s   ròcs%tjˆƒ‡fdd†ƒ}|S)z5Skip the test on TLS certificate validation failures.csdyˆ||ŽWnLtk r_}z,dt|ƒkrJtjdƒ‚n‚WYdd}~XnXdS)NZCERTIFICATE_VERIFY_FAILEDz.system does not contain necessary certificates)ÚIOErrorrercrd)rØÚkwargsrÏ)rrrTrUÚdec»s z&system_must_validate_cert..dec)ràrá)rrrõrT)rrrUÚsystem_must_validate_cert¹s! rör†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|ƒ}nRytj|ƒd}Wn8tk rŠ|sl‚ntjd|t ddƒYnXz |VWd|r­t j |ƒnXdS)a¢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. FNTz+tests may fail, unable to create temp dir: r…é) ÚtempfileZmkdtemprurvÚrealpathÚmkdirr›rWr‹rŒÚshutilr)rvÚquietZ dir_createdrTrTrUÚtemp_dirks"       rccs|tjƒ}ytj|ƒWn8tk rW|s9‚ntjd|tddƒYnXztjƒVWdtj|ƒXdS)agReturn 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. z)tests may fail, unable to change CWD to: r…r N)ruÚgetcwdÚchdirr›rWr‹rŒ)rvrZ saved_dirrTrTrUÚ change_cwd�s   rZtempcwdccsBtd|d|ƒ�'}t|d|ƒ� }|VWdQXWdQXdS)aö 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. rvrN)rr)rfrZ temp_pathZcwd_dirrTrTrUr¨sÚumaskc cs-tj|ƒ}z dVWdtj|ƒXdS)z8Context manager that temporarily sets the process umask.N)rur)rZoldmaskrTrTrUr?¼s ÚdatacCsŠtjj|ƒr|S|dk r:tjj||ƒ}ntgtj}x9|D]1}tjj||ƒ}tjj|ƒrQ|SqQW|S)a[Try to find a file on sys.path or in the test 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). Setting *subdir* indicates a relative path to use to find the file rather than looking directly in the path directories. N)rurvÚisabsr˜Ú TEST_HOME_DIRr_Úexists)r“ZsubdirrvZdnÚfnrTrTrUrÍs  cCs4tj|tjtjBtjBƒ}tj|ƒdS)z>Create an empty file. If the file already exists, truncate it.N)ruÚopenÚO_WRONLYÚO_CREATÚO_TRUNCrå)r“ÚfdrTrTrUrßs#cCs<t|jƒƒ}dd„|Dƒ}dj|ƒ}d|S)z%Like repr(dict), but in sorted order.cSsg|]}d|‘qS)z%r: %rrT)Ú.0ZpairrTrTrUú çs zsortdict..z, z{%s})Úsortedr{r˜)Údictr{Z reprpairsZ withcommasrTrTrUrNäsc Cs9ttdƒ}z|jƒSWd|jƒttƒXdS)z` Create an invalid file descriptor by opening and closing a file and return its fd. ÚwbN)rrÚfilenorår)r—rTrTrUÚ make_bad_fdës  r'cCs|jtt|ddƒdS)Nz Úexec)Z assertRaisesÚ SyntaxErrorÚcompile)ZtestcaseZ statementrTrTrUr"÷sc sÒddl}ddl}ˆjddƒ‰|jj|ƒdjdƒd}tjjt |ƒ}‡‡‡fdd†}tjj |ƒrµ||ƒ}|dk r¨|St |ƒnt dƒt d |d tƒƒ|jjƒ}trþ|jjdƒn|j|d dƒ}trF|jjdƒd krFtjd|ƒ}nzNt|dƒ�9} |jƒ} x#| rŒ| j| ƒ|jƒ} qjWWdQXWd|jƒX||ƒ}|dk r¾|Std|ƒ‚dS)NrÚcheckr„ú/r€csMt|ˆˆŽ}ˆdkr"|Sˆ|ƒr?|jdƒ|S|jƒdS)Nr)rÚseekrå)rrr)rØr+rÙrTrUÚcheck_valid_files   z*open_urlresource..check_valid_fileZurlfetchz fetching %s ...r—úAccept-EncodingÚgzipr�ézContent-EncodingZfileobjr%zinvalid resource %réÿÿÿÿ)r/zgzip)Zurllib.requestZ urllib.parseÚpopÚparseZurlparser‡rurvr˜Ú TEST_DATA_DIRrrrrœrZrequestZ build_openerr0Z addheadersrzrZheadersÚgetZGzipFileÚreadÚwriterår) ZurlrØrÙÚurllibr“rr.rrZopenerÚoutÚsrT)rØr+rÙrUr>ûs:#           c@sLeZdZdZdd„Zdd„Zedd„ƒZdd „Zd S) ÚWarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS)Nr)Ú _warningsÚ_last)ÚselfZ warnings_listrTrTrUÚ__init__0s zWarningsRecorder.__init__cCs\t|jƒ|jkr,t|jd|ƒS|tjjkrBdStd||fƒ‚dS)Nr€z%r has no attribute %rr2)rÈr=r>r}rWÚWarningMessageÚ_WARNING_DETAILSr~)r?ÚattrrTrTrUÚ __getattr__4s zWarningsRecorder.__getattr__cCs|j|jd…S)N)r=r>)r?rTrTrUrW;szWarningsRecorder.warningscCst|jƒ|_dS)N)rÈr=r>)r?rTrTrUÚreset?szWarningsRecorder.resetN) rPrQrRrSr@rDÚpropertyrWrErTrTrTrUr<,s   r<c csltjdƒ}|jjdƒ}|r4|jƒntjddƒ�&}tjdjdƒt |ƒVWdQXt |ƒ}g}x«|D]£\}}d} xg|dd…D]U}|j } t j |t| ƒt jƒrªt| j|ƒrªd} |j|ƒqªqªW| r‡| r‡|j||jfƒq‡q‡W|rKtd |d ƒ‚n|rhtd |d ƒ‚ndS) z¶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. r„Z__warningregistry__ÚrecordTrWÚalwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)r_Ú _getframeÚ f_globalsr6ÚclearrWrXrjÚ simplefilterr<rlÚmessageÚreÚmatchreÚIÚ issubclassÚ __class__ÚremoverzrPÚAssertionError) ÚfiltersrZframeÚregistryÚwZreraiseZmissingrhÚcatÚseenZwarningrTrTrUÚ_filterwarningsCs0   rZcOsI|jdƒ}|s<dtff}|dkr<d}q<nt||ƒS)a˜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ÚNT)r6ÚWarningrZ)rUrôrrTrTrUrFjs   c@s:eZdZdZdd„Zdd„Zdd„ZdS) r a,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)r_rjÚcopyÚoriginal_modulesrP)r?Z module_namesZ module_namer|rTrTrUr@Žs  zCleanImport.__init__cCs|S)NrT)r?rTrTrUÚ __enter__›szCleanImport.__enter__cGstjj|jƒdS)N)r_rjrÆr^)r?Ú ignore_excrTrTrUÚ__exit__žszCleanImport.__exit__N)rPrQrRrSr@r_rarTrTrTrUr ‚s  c@sšeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„ZdS)rGz_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS)N)ruríÚ_environÚ_changed)r?rTrTrUr@§s zEnvironmentVarGuard.__init__cCs |j|S)N)rb)r?ÚenvvarrTrTrUÚ __getitem__«szEnvironmentVarGuard.__getitem__cCs<||jkr+|jj|ƒ|j|@Úerrnosc #sÕdd d!d"d#g}d%d'd)d+d,g}td|ƒ‰|‰g‰ˆsudd„|Dƒ‰dd„|Dƒ‰n‡‡‡fdd†}tjƒ}z'y%|dk r»tj|ƒndVWnûtjk r}z2trýtjj ˆj ddƒnˆ|‚WYdd}~Xn§t k r¾}z‡xr|j }t |ƒdkrht |dt ƒrh|d}q-t |ƒdkršt |dt ƒrš|d}q-Pq-W||ƒ‚WYdd}~XnXWdtj|ƒXdS)-z‹Return a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.Ú 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||ƒ‘qSrT)r}rx)r!rfÚnumrTrTrUr")s z&transient_internet..cSs(g|]\}}tt||ƒ‘qSrT)r}rä)r!rfr‹rTrTrUr"+s csét|ddƒ}t|tjƒsµt|tjƒrB|ˆksµt|tjjƒrvd|jkoqdknsµt|tjj ƒr©d|j ksµd|j ksµ|ˆkråt sÙt j jˆjddƒnˆ|‚ndS)NrxiôiWÚConnectionRefusedErrorÚ TimeoutErrorrÚ )r}Ú isinstancerär�Zgaierrorr9ÚerrorZ HTTPErrorÚcodeZURLErrorrËrr_Ústderrr8rØ)ÚerrÚn)Úcaptured_errnosÚdeniedÚ gai_errnosrTrUÚ filter_error.s z(transient_internet..filter_errorNrrŽr€)rzr{)z ECONNRESETr})r~r)r€r�)z ETIMEDOUTrƒéýÿÿÿ)r„r™éüÿÿÿ)r…ršéþÿÿÿ)r†r›éûÿÿÿ)r‡rœ)r‰rŠ)r räZgetdefaulttimeoutZsetdefaulttimeoutÚnntplibZNNTPTemporaryErrorrr_r’r8rØr›rÈr�) Z resource_namer�ryZdefault_errnosZdefault_gai_errnosr˜Z old_timeoutr“ÚarT)r•r–r—rUr'sN          % %  c cs[ddl}tt|ƒ}tt||jƒƒztt|ƒVWdtt||ƒXdS)z‰Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO.rN)Úior}r_ÚsetattrÚStringIO)Z stream_namerŸZ orig_stdoutrTrTrUÚcaptured_output[s  r¢cCs tdƒS)z Capture the output of sys.stdout: with captured_stdout() as stdout: print("hello") self.assertEqual(stdout.getvalue(), "hello\n") r‚)r¢rTrTrTrUrgscCs tdƒS)z±Capture the output of sys.stderr: with captured_stderr() as stderr: print("hello", file=sys.stderr) self.assertEqual(stderr.getvalue(), "hello\n") r’)r¢rTrTrTrUrpscCs tdƒS)a Capture the input to sys.stdin: with captured_stdin() as stdin: stdin.write('hello\n') stdin.seek(0) # call test code that consumes from sys.stdin captured = input() self.assertEqual(captured, "hello") Ústdin)r¢rTrTrTrUrys cCs8tjƒtr tjdƒntjƒtjƒdS)aÚ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)ÚgcZcollectr8r‰rŠrTrTrTrUÚ gc_collect†s  r¥c cs:tjƒ}tjƒz dVWd|r5tjƒnXdS)N)r¤Ú isenabledÚdisableÚenable)Zhave_gcrTrTrUÚ disable_gc–s    r©cCsTtjdƒpd}d}x,|jƒD]}|jdƒr(|}q(q(W|dkS)z,Find if Python was built with optimizations.Ú PY_CFLAGSr[z-Oú-O0ú-Og)r[r«r¬)Ú sysconfigÚget_config_varr‡ra)ZcflagsZ final_optZoptrTrTrUÚpython_is_optimized¡s  r¯ZnPZ0nÚgettotalrefcountZ2PZ0Pr”cCstjt|tƒS)N)ÚstructÚcalcsizeÚ_headerÚ_align)ÚfmtrTrTrUÚ calcobjsize²sr¶cCstjt|tƒS)N)r±r²Ú_vheaderr´)rµrTrTrUÚ calcvobjsizeµsr¸éé cCsŸddl}tj|ƒ}t|ƒtkr:|jt@s_t|ƒtkrot|ƒjt@ro||j7}ndt|ƒ||f}|j|||ƒdS)Nrz&wrong size for %s: got %d, expected %d) Ú _testcapir_Ú getsizeofrÊÚ __flags__Ú_TPFLAGS_HEAPTYPEÚ_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADZ assertEqual)Útestr¨Úsizer»r±rhrTrTrUÚ 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||ƒnXdS)Nr)Úlocaler}Ú setlocaler~)rØÚkwdsrÃÚcategoryZ orig_localeÚloc)Úcatstrr�ÚlocalesrTrUÚinnerÍs$     z1run_with_locale..decorator..inner)rPrS)r�rÊ)rÈrÉ)r�rUrâÌs  z"run_with_locale..decoratorrT)rÈrÉrârT)rÈrÉrUrHËscs‡fdd†}|S)Ncs1‡‡fdd†}ˆj|_ˆj|_|S)Ncs³y tj}Wn!tk r0tjdƒ‚YnXdtjkrPtjd}nd}ˆtjd<|ƒzˆ||ŽSWd|dkr—tjd=n |tjd.decorator..inner)rPrS)r�rÊ)rÌ)r�rUrâðs  zrun_with_tz..decoratorrT)rÌrârT)rÌrUrOïscCsäidd6td6td6dtd6}tjd|tjtjBƒ}|dkrgtd|fƒ‚ntt|j dƒƒ||j d ƒj ƒƒ}|a |t kr´t }n|t dkrÚtd |fƒ‚n|adS) NiroÚmÚgÚtz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rr€r z$Memory limit %r too low to be useful)Ú_1MÚ_1GrNrOÚ IGNORECASEÚVERBOSEr×rÖÚfloatÚgroupÚlowerÚreal_max_memuseÚMAX_Py_ssize_tÚ_2Gr)ÚlimitZsizesrÍZmemlimitrTrTrUrLs   2  c@s:eZdZdZdd„Zdd„Zdd„ZdS) Ú_MemoryWatchdogz`An object which periodically watches the process' memory consumption and prints it out. cCs(djdtjƒƒ|_d|_dS)Nz/proc/{pid}/statmÚpidF)rÉruÚgetpidÚprocfileÚstarted)r?rTrTrUr@3sz_MemoryWatchdog.__init__cCsµyt|jdƒ}WnOtk rg}z/tjdj|ƒtƒtjj ƒdSWYdd}~XnXt dƒ}t j tj |gd|dt jƒ|_|jƒd|_dS)NÚrz!/proc not available for stats: {}zmemory_watchdog.pyr£r’T)rrÞr›rWr‹rÉrŒr_r’ÚflushrÚ subprocessÚPopenÚ executableZDEVNULLÚ mem_watchdogrårß)r?rrrÏZwatchdog_scriptrTrTrUÚstart7s   z_MemoryWatchdog.startcCs*|jr&|jjƒ|jjƒndS)N)rßråZ terminateÚwait)r?rTrTrUÚstopFs  z_MemoryWatchdog.stopN)rPrQrRrSr@rærèrTrTrTrUrÛ.s   rÛcs‡‡‡fdd†}|S)aADecorator 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. if 'dry_run' is False, it means the test doesn't support dummy runs when -M is not specified. cs.‡‡‡fdd†‰ˆˆ_ˆˆ_ˆS)Nc sÛˆj}ˆj}ts!d}n|}ts4ˆ rbt||krbtjd||dƒ‚ntr©tr©tƒtdjd||dƒƒtƒ}|j ƒnd}zˆ||ƒSWd|rÖ|j ƒnXdS) Niz'not enough memory: %.1fG minimum neededir z* ... expected peak memory use: {peak:.1f}GZpeaki@i@) rÁÚmemuser×rcrdrrœrÉrÛrærè)r?rÁréÚmaxsizeZwatchdog)Údry_runrrrßrTrUrßWs*        z.bigmemtest..decorator..wrapper)rÁré)rr)rërérÁ)rrrßrUrâVs  zbigmemtest..decoratorrT)rÁrérërârT)rërérÁrUr/Ls !cs‡fdd†}|S)z0Decorator for tests that fill the address space.cs^ttkrPtd kr6td kr6tjdƒ‚qZtjdtd ƒ‚n ˆ|ƒSdS) Nr„é?r€éz-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir llÿÿÿÿli@)rrØrcrd)r?)rrrTrUrß{s  z!bigaddrspacetest..wrapperrT)rrrßrT)rrrUr0ys c@seZdZdd„ZdS)r(cCstjƒ}||ƒ|S)N)rcZ TestResult)r?rÀr±rTrTrUÚrunŒs  zBasicTestRunner.runN)rPrQrRrîrTrTrTrUr(‹s cCs|S)NrT)rrTrTrUÚ_id‘srïcCsP|dkr&tƒ r&tjtjƒSt|ƒr6tStjdj|ƒƒSdS)NrÑzresource {0!r} is not enabled)rÂrcÚskiprËrrïrÉ)rÐrTrTrUÚrequires_resource”s  rñcCstddƒ|ƒS)z9 Decorator for tests only applicable on CPython. ÚcpythonT)Ú impl_detail)rÀrTrTrUr1œscKs}t|�rtS|dkrpt|ƒ\}}|r=d}nd}t|jƒƒ}|jdj|ƒƒ}ntj|ƒS)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or ) r9rïÚ _parse_guardsr#rirÉr˜rcrð)rhÚguardsZ guardnamesÚdefaultrTrTrUró¢s   rócCsc|sidd6dfSt|jƒƒd}t|jƒƒ|gt|ƒksXt‚|| fS)NTròFr)rlÚvaluesrÈrT)rõZis_truerTrTrUrô¯s +rôcKs.t|ƒ\}}|jtjƒjƒ|ƒS)a5This 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ôr6r`Zpython_implementationrÖ)rõrörTrTrUr9¹scs<ttdƒsˆStjˆƒ‡fdd†ƒ}|SdS)zEDecorator to temporarily turn off tracing for the duration of a test.Úgettracec s?tjƒ}ztjdƒˆ||ŽSWdtj|ƒXdS)N)r_røÚsettrace)rØrôZoriginal_trace)r�rTrUrßÉs   zno_tracing..wrapperN)rÁr_ràrá)r�rßrT)r�rUÚ no_tracingÄs!rúcCstt|ƒƒS)aDecorator for tests which involve reference counting. To start, the decorator does not run the test if is not run by CPython. After that, any trace function is unset during the test to prevent unexpected refcounts caused by the trace function. )rúr1)rÀrTrTrUÚ refcount_testÔsrûcCsrg}x\|jD]Q}t|tjƒrEt||ƒ|j|ƒq||ƒr|j|ƒqqW||_dS)z>Recursively filter test cases in a suite based on a predicate.N)Z_testsr�rcÚ TestSuiteÚ _filter_suiterz)ÚsuiteZpredZnewtestsrÀrTrTrUrýßs  rýcCsÝtr'tjtjdddtƒ}n tƒ}|j|ƒ}|jƒsÙt |j ƒdkr~|j r~|j dd}nLt |j ƒdkr±|j r±|j dd}nd}tsÊ|d7}nt |ƒ‚ndS) z2Run tests from a unittest.TestSuite-derived class.Ú verbosityr„rr€rzmultiple errors occurredz!; run in verbose mode for detailsN) rrcZTextTestRunnerr_r‚rr(rîZ wasSuccessfulrÈÚerrorsZfailuresr)rþZrunnerr±r“rTrTrUÚ _run_suiteës    rcGsØtjtjf}tjƒ}x�|D]ˆ}t|tƒrx|tjkri|jtjtj|ƒƒq­t dƒ‚q%t||ƒr—|j|ƒq%|jtj |ƒƒq%Wdd„}t ||ƒt |ƒdS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulescSsJtdkrdSx3|jƒjdƒD]}tj|tƒr&dSq&WdS)NTriF)Ú match_testsÚidr‡ÚfnmatchZ fnmatchcase)rÀrfrTrTrUÚ case_pred s  zrun_unittest..case_predN) rcrüZTestCaser�rer_rjZaddTestZ findTestCasesr×Z makeSuiterýr)ZclassesZ valid_typesrþÚclsrrTrTrUr)ÿs     cCsdS)z,Just used to check if docstrings are enabledNrTrTrTrTrUÚ_check_docstringssrÚwin32ÚWITH_DOC_STRINGSztest requires docstringscCs‘ddl}|dkr!t}nd}|j|d|d|ƒ\}}|rgtd||fƒ‚ntr‡td|j|fƒn||fS)aRun doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). rNrÚ optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)ÚdoctestrZtestmodrrœrP)r|rÿr r rrrÏrTrTrUr*.s   !cCstjjƒfS)N)r_rjr]rTrTrTrUÚ modules_setupIsr cCsMdd„tjjƒDƒ}tjjƒtjj|ƒtjj|ƒdS)NcSs1g|]'\}}|jdƒr||f‘qS)z encodings.)ra)r!rorprTrTrUr"Ps z#modules_cleanup..)r_rjr{rKrÆ)Z oldmodulesÚ encodingsrTrTrUÚmodules_cleanupLs rcCs-trtjƒtjjƒfSdffSdS)Nr€)Ú_threadÚ_countÚ threadingÚ _danglingr]rTrTrTrUrBgscGsdts dSd}xMt|ƒD]?}tjƒtjf}||krHPntjdƒtƒqWdS)Nédg{®Gáz„?)rÚrangerrrr‰rŠr¥)Zoriginal_valuesZ _MAX_COUNTÚcountr÷rTrTrUrCms  cs/ts ˆStjˆƒ‡fdd†ƒ}|S)z¿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. c s)tƒ}zˆ|ŒSWdt|ŒXdS)N)rBrC)rØÚkey)r�rTrUrâ�s zreap_threads..decorator)rràrá)r�rârT)r�rUrDys!c Cs^ttdƒrZd}xBy/tj|tjƒ\}}|dkrFPnWqPYqXqWndS)zå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. Úwaitpidr€rNr2)rÁrurÚWNOHANG)Z any_processrÜZstatusrTrTrUr@Šs  ccs…t|ƒ}g}zly,x%|D]}|jƒ|j|ƒqWWn4trptdt|ƒt|ƒfƒn‚YnXdVWdz¹|r”|ƒntjƒ}}x’tddƒD]�}|d7}x.|D]&}|jt |tjƒdƒƒqËWdd„|Dƒ}|sPntr´tdt|ƒ|fƒq´q´WWdd d„|Dƒ}|rt j t j ƒtd t|ƒƒ‚nXXdS) Nz/Can't start %d threads, only %d threads startedr€r÷é<g{®Gáz„?cSs"g|]}|jƒr|‘qSrT)ÚisAlive)r!rÏrTrTrUr"¶s z!start_threads..z7Unable to join %d threads during a period of %d minutescSs"g|]}|jƒr|‘qSrT)r)r!rÏrTrTrUr"½s zUnable to join %d threads)rlrærzrrœrÈr‰rr˜ÚmaxÚ faulthandlerZdump_tracebackr_r‚rT)ZthreadsZunlockrßrÏZendtimeZ starttimer�rTrTrUrEžs>       $c cs|t||ƒrNt||ƒ}t|||ƒz dVWdt|||ƒXn*t|||ƒz dVWdt||ƒXdS)amTemporary 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)rÁr}r Údelattr)rrCÚnew_valÚreal_valrTrTrUrJÂs   c cs\||kr:||}|||}||}|j|ƒ}|j|||ƒs d}Pq q W|S)a. Try to match a single dict with the supplied arguments. Keys whose values are strings and which are in self._partial_matches will be checked for partial (i.e. substring) matches. You can extend this scheme to (for example) do regular expression matching, etc. TF)r6Ú match_value)r?r/rôr±rorpÚdvrTrTrUr.+s  zMatcher.matchescCsjt|ƒt|ƒkr!d}nEt|ƒtk sB||jkrQ||k}n|j|ƒdk}|S)zT Try to match a single stored value (dv) with a supplied value (v). Fr)rÊreÚ_partial_matchesÚfind)r?ror1rpr±rTrTrUr0<s  !zMatcher.match_valueN)zmsgzmessage)rPrQrRr2r.r0rTrTrTrUrK's  c Csotdk rtStd}ytjt|ƒd}Wn!tttfk rWd}YnXtj|ƒ|a|S)NrTF)Ú _can_symlinkrruÚsymlinkr›ÚNotImplementedErrorr~rS)Z symlink_pathÚcanrTrTrUrJs     cCs,tƒ}d}|r|Stj|ƒ|ƒS)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)rrcrð)rÀÚokrhrTrTrUr+Ys cCstdk rtSttdƒs(d}nÖtjƒ\}}z¬ttdƒ�—}yutj|ddƒtj|jƒddƒt j ƒ}t j d|ƒ}|dkpÀt |jdƒƒdk}Wntk rÞd}YnXWdQXWdttƒt|ƒX|a|S) NÚsetxattrFr%s user.testr!z 2.6.(\d{1,2})r€é')Ú _can_xattrrÁrur Zmkstemprrr9r&r`rÔrNrOrÖrÕr›r)r7Ztmp_fpZtmp_nameÚfpZkernel_versionrÍrTrTrUÚ can_xattr`s&   +   r=cCs,tƒ}d}|r|Stj|ƒ|ƒS)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)r=rcrð)rÀr8rhrTrTrUr4{s cCstjd|ƒ�g}|j}|jƒ}||krE|jƒ}nytjj||ƒSWntk rtdSYnXWdQXdS)zKDetects if the file system for the specified directory is case-insensitive.ÚdirFN) r ZNamedTemporaryFilerfÚupperrÖrurvÚsamefiler¥)Z directoryÚbaseÚ base_pathZ case_pathrTrTrUr‚s    c@s4eZdZdZdZdd„Zdd„ZdS)rMz«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. NcCs4tjjdƒrbddl}|jj|_d}|jj|ƒ|_|jj|j|BƒnÎt dk rÅy9t j t j ƒ|_t j t j d|jdfƒWqÅt tfk rÁYqÅXntjdkr0tjddd d gd tjƒjƒd}|jƒd kr0td ddddƒq0n|S)z»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ƒrNr„r€r¸z/usr/bin/defaultsr7zcom.apple.CrashReporterZ DialogTyper‚s developerz:this test triggers the Crash Reporter, that is intentionalÚendr[ráT)r_r`rar¶rÃZkernel32Ú_k32Ú SetErrorModeÚ old_valuerÐZ getrlimitÚ RLIMIT_COREÚ setrlimitr×r›rârãÚPIPEZ communicater#rœ)r?r¶ZSEM_NOGPFAULTERRORBOXrfrTrTrUr_—s*      zSuppressCrashReport.__enter__c Gsƒ|jdkrdStjjdƒr;|jj|jƒnDtdk rytjtj|jƒWqt t fk r{YqXndS)zARestore Windows ErrorMode or core file behavior to initial value.Nrƒ) rFr_r`rarDrErÐrHrGr×r›)r?r`rTrTrUra¿s zSuppressCrashReport.__exit__)rPrQrRrSrFr_rarTrTrTrUrM�s  (c s“tˆˆƒd‰yˆjˆ‰Wn*ttfk rPtˆˆdƒ‰YnXd‰‡‡‡‡fdd†}|j|ƒtˆˆ|ƒdS)zóOverride 'object_to_patch'.'attr_name' with 'new_value'. Also, add a cleanup procedure to 'test_instance' to restore 'object_to_patch' value for 'attr_name'. The 'attr_name' should be a valid attribute for 'object_to_patch'. FNTcs*ˆrtˆˆˆƒn tˆˆƒdS)N)r rrT)Ú attr_is_localÚ attr_nameÚobject_to_patchrFrTrUÚcleanupäszpatch..cleanup)r}r,r~rpZ addCleanupr )Z test_instancerLrKZ new_valuerMrT)rJrKrLrFrUÚpatchÎs  rNc Cs\yddl}Wntk r$YnX|jƒrCtjdƒ‚nddl}|j|ƒS)zi Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc module is enabled. rNzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations)Ú tracemallocr^Z is_tracingrcrdr»Úrun_in_subinterp)r‘rOr»rTrTrUrPðs   rPii@i@i@ii) rùrúrûrürýrþrÿrrrr)zntr)rrr r r i@ii)êrSrPr^Zcollections.abcÚ collectionsÚ contextlibrxrrràr¤r]Úimportlib.utilZlogging.handlersr&r�rur`rNrräržr±râr_r­r r‰rcZ urllib.errorr9rWrrZmultiprocessing.processZmultiprocessingÚzlibr0Úbz2ZlzmarÐÚ__all__rÇrrrdr Úcontextmanagerr[r rorqr6r7r r2rrrr×rrr�rrr rar’r”r–r¤rr•rr¯rrÂrrrãrr r!r:rñrërìr<r=ròr;rörZ SOCK_MAX_SIZEZ skipUnlessrÔÚ __getformat__r3r5r,r-r.r8rfrrÉrÝZ FS_NONASCIIÚ characterÚfsdecodeÚfsencodeÚ UnicodeErrorZTESTFN_UNICODEZ unicodedataÚ normalizeÚgetfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversionÚencodeÚUnicodeEncodeErrorrœÚdecodeÚUnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIrrrrrrÁr?rvrwr«rxZTEST_SUPPORT_DIRrr˜r5rrrNr'r"r>Úobjectr<rZrFr ÚabcÚMutableMappingrGrqr#r›r‚r$r|r%r&r'r¢rrrr¥r©r¯r³r´r·r¶r¸r¿r¾rÂrHrOrÐrÑrÙZ_4GrêrØrLrÛr/r0r(rïrñr1rórôr9rúrûrýrr)rr®ZMISSING_C_DOCSTRINGSZHAVE_DOCSTRINGSZrequires_docstringsr*r rrBrCrDr@rErJrIr$r%r'r(rArKr4rr+r;r=r4rrMrNrPrTrTrTrUÚsb                                                          2    !           I   >&                  !     1' 5 I         $ #     -                # "     ? "