Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/test/support/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/test/support/__pycache__/__init__.cpython-33.pyc

�
��f<cz@s�
dZedkr!ed��nddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZddlZWnek
redZdZYnXyddlZWnek
r�dZYnXyddl Z Wnek
r�dZ YnXyddl!Z!Wnek
r�dZ!YnXyddl"Z"Wnek
rdZ"YnXyddl#Z#Wnek
r<dZ#YnXddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNgJZ$GdOd�de%�Z&GdPd�de&�Z'GdQd�de
j(�Z)ej*ddRdS��Z,ddTd�Z.dUdV�Z/dWdX�Z0dYdI�Z1ffddZdE�Z2d[d<�Z3d\Z4dZ5da6da7dZ8dZ9da:d]d�Z;d^d
�Z<d_d�Z=ej
j>d`�rhddadb�Z?dcdd�Z@dedf�ZAdgdh�ZBne	jCZ@e	jDZAejEZBdid�ZCdjdk�ZDdld�ZEdmdn�ZFdod�ZGej
j>d`�r�ddlHZHddlIZHdpdq�ZJndrdq�ZJdsd�ZKddtd�ZLdudv�ZMdwd�ZNdxd�ZOdyd�ZPdzZQd{ZRejSejTd|d�ZUeQd}d�ZVd~d�ZWeW�ZXdZYd"ZZe
j[e\j]d��j>d��d��Z^e
j[e d��Z_e
j[e!d��Z`e
j[e"d��Zae
j[e#d��Zbej
j>d��Zce	jdd�kr9d�Zend�Zed�jfeee	jg��ZedZhxDd#D]<Ziye	jje	jkei��Wnelk
r�YqdXeiZhPqdWeed�Zmej
d�kr�ddlnZnenjod�em�Zmnejp�ZqdZre	jdd$krdejs�j
d�kr�eed�Zryerjteq�Wneuk
rCYqaXevd�ereqf�dZrq�nNej
d�kr�yd�jweq�Wq�exk
r�eed�jweqd��ZrYq�XndZyxHd%D]@Zdyedjweq�Wq�exk
r�e	jkee�edZyPYq�Xq�Wehreed�ehZzndZze	j{�Z|ej*ddd�d���Z}ej*dd�d���Z~ej*d�dd�d��Ze�e	d��r�ej*d�d/��Z�ne	j�j�e	j�j�e���Z�e	j�j�e��Z�e	j�j�e�d��Z�dd�d�Z�d�d �Z�d�d!�Z�d�d��Z�d�d"�Z�d�d#�Z�Gd�d��d�e��Z�dd�d��Z�ej*d�d$��Z�Gd�d%�d%e��Z�Gd�d&�d&ej�j��Z�Gd�d��d�e��Z�Gd�d'�d'e��Z�e�e�d�ej��Z�e�ej�d�ej��Z�e�e�d�ej��Z�ej*d�d�d�fd�d0��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�d&Z�d'Z�d�d��Z�d�d.�Z�d�dJ�Z�d(Z�d�e�Z�d�e�Z�d�e�Z�ej�Z�d�d1�Z�Gd�d��d��Z�dd�d2�Z�d�d3�Z�Gd�d4�d4�Z�d�d��Z�d�d��Z�d�d:�Z�dd�d��Z�d�d��Z�d�d;�Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d5�Z�e�d�d�p=ej
d�kp=ej�d��Z�e
j[e�d��Z�dddd6�Z�dd�Z�dd�Z�dd7�Z�dd8�Z�dd�Z�d	d9�Z�ej*d
d>��Z�ej*dd=��Z�dd
�Z�dd�Z�Gdd@�d@ej�j��Z�GddA�dAe��Z�da�ddB�Z�ddC�Z�da�dd�Z�ddD�Z�ej
j>d`�r�
ej*ddN��Z�nej*ddN��Z�dd�Z�dS()u7Supporting definitions for the Python regression tests.utest.supportu.support must be imported from the test packageiNuErroru
TestFaileduResourceDeniedu
import_moduleuverboseu
use_resourcesu
max_memuseurecord_original_stdoutuget_original_stdoutuunloaduunlinkurmtreeuforgetuis_resource_enabledurequiresurequires_freebsd_versionurequires_linux_versionurequires_mac_verufind_unused_portu	bind_portuIPV6_ENABLEDu	is_jythonuTESTFNuHOSTuSAVEDCWDutemp_cwdufindfileucreate_empty_fileusortdictucheck_syntax_erroruopen_urlresourceucheck_warningsuCleanImportuEnvironmentVarGuarduTransientResourceucaptured_stdoutucaptured_stdinucaptured_stderrutime_outusocket_peer_resetuioerror_peer_reseturun_with_localeu
temp_umaskutransient_internetuset_memlimitu
bigmemtestubigaddrspacetestuBasicTestRunnerurun_unittesturun_doctestuthreading_setuputhreading_cleanupu
reap_childrenucpython_onlyucheck_impl_detailu
get_attributeu	swap_itemu	swap_attrurequires_IEEE_754uTestHandleruMatcherucan_symlinkuskip_unless_symlinkuskip_unless_xattruimport_fresh_moduleu
requires_zlibu
PIPE_MAX_SIZEufailfastuanticipate_failureurun_with_tzu
requires_gzipurequires_bz2u
requires_lzmausuppress_crash_popupcBs|EeZdZdZdS(uErroru*Base class for regression test exceptions.N(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuErrorQscBs|EeZdZdZdS(u
TestFaileduTest failed.N(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
TestFailedTscBs|EeZdZdZdS(uResourceDeniedu�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(u__name__u
__module__u__qualname__u__doc__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuResourceDeniedWsccs=|r4tj��tjddt�dVWdQXndVdS(u�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.uignoreu.+ (module|package)N(uwarningsucatch_warningsufilterwarningsuDeprecationWarning(uignore((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_ignore_deprecated_imports_s
u_ignore_deprecated_importscCset|��Sytj|�SWn:tk
rZ}ztjt|���WYdd}~XnXWdQXdS(u�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(u_ignore_deprecated_importsu	importlibu
import_moduleuImportErroruunittestuSkipTestustr(unameu
deprecatedumsg((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
import_modulens

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

    Raise ImportError if the module can't be imported.
    u.N(usysumodulesu
__import__ulistu
startswith(unameuorig_modulesumodname((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_save_and_remove_module{s

u_save_and_remove_modulecCsGd}ytj|||<Wntk
r5d}YnXdtj|<|S(u�Helper function to save and block a module in sys.modules

    Return True if the module was in sys.modules, False otherwise.
    TFN(uTrueusysumodulesuKeyErroruFalseuNone(unameuorig_modulesusaved((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_save_and_block_module�s

u_save_and_block_modulecCs|r
tjSdd�S(u�Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    cSs|S(N((uf((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu<lambda>�su$anticipate_failure.<locals>.<lambda>(uunittestuexpectedFailure(u	condition((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuanticipate_failure�scCs�t|���i}g}t||�z�yax|D]}t||�q3Wx-|D]%}t||�sQ|j|�qQqQWtj|�}Wntk
r�d}YnXWdx'|j�D]\}	}
|
t	j
|	<q�Wx|D]}t	j
|=q�WX|SWdQXdS(u�Import and return a module, deliberately bypassing sys.modules.

    This function imports and returns a fresh copy of the named Python module
    by removing the named module from sys.modules before doing the import.
    Note that unlike reload, the original module is not affected by
    this operation.

    *fresh* is an iterable of additional module names that are also removed
    from the sys.modules cache before doing the import.

    *blocked* is an iterable of module names that are replaced with None
    in the module cache during the import to ensure that attempts to import
    them raise ImportError.

    The named module and any modules named in the *fresh* and *blocked*
    parameters are saved before starting the import and then reinserted into
    sys.modules when the fresh import is complete.

    Module and package deprecation messages are suppressed during this import
    if *deprecated* is True.

    This function will raise ImportError if the named module cannot be
    imported.
    N(u_ignore_deprecated_importsu_save_and_remove_moduleu_save_and_block_moduleuappendu	importlibu
import_moduleuImportErroruNoneuitemsusysumodules(unameufreshublockedu
deprecateduorig_modulesunames_to_removeu
fresh_nameublocked_nameufresh_moduleu	orig_nameumoduleuname_to_remove((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuimport_fresh_module�s$





cCsIyt||�}Wn+tk
r@tjd||f��YnX|SdS(u?Get an attribute, raising SkipTest if AttributeError is raised.uobject %r has no attribute %rN(ugetattruAttributeErroruunittestuSkipTest(uobjunameu	attribute((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
get_attribute�s

icCs
|adS(N(u_original_stdout(ustdout((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurecord_original_stdout�scCs
tptjS(N(u_original_stdoutusysustdout(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuget_original_stdout�scCs'ytj|=Wntk
r"YnXdS(N(usysumodulesuKeyError(uname((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuunload�s
uwincCs�||�|r|}n$tjj|�\}}|p:d}d}xR|dkr�tj|�}|rm|n	||ks}dStj|�|d9}qFWtjd|tdd�dS(Nu.g����MbP?g�?iu)tests may fail, delete still pending for u
stackleveli(	uosupathusplitulistdirutimeusleepuwarningsuwarnuRuntimeWarning(ufuncupathnameuwaitalludirnameunameutimeoutuL((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_waitfor�s
	

u_waitforcCsttj|�dS(N(u_waitforuosuunlink(ufilename((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_unlinksu_unlinkcCsttj|�dS(N(u_waitforuosurmdir(udirname((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_rmdirsu_rmdircs9�fdd��t�|dd�ttj|�dS(Ncsuxntj|�D]]}tjj||�}tjj|�r`t�|dd�tj|�qtj|�qWdS(NuwaitallT(	uosulistdirupathujoinuisdiru_waitforuTrueurmdiruunlink(upathunameufullname(u
_rmtree_inner(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
_rmtree_innersu_rmtree.<locals>._rmtree_inneruwaitallT(u_waitforuTrueuosurmdir(upath((u
_rmtree_inneru:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_rmtreesu_rmtreecCs[yt|�WnFtk
rV}z&|jtjtjfkrD�nWYdd}~XnXdS(N(u_unlinkuOSErroruerrnouENOENTuENOTDIR(ufilenameuerror((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuunlink.s
cCsRyt|�Wn=tk
rM}z|jtjkr;�nWYdd}~XnXdS(N(u_rmdiruOSErroruerrnouENOENT(udirnameuerror((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurmdir6s
urmdircCsRyt|�Wn=tk
rM}z|jtjkr;�nWYdd}~XnXdS(N(u_rmtreeuOSErroruerrnouENOENT(upathuerror((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurmtree>s
cCsftj|�}tjjtjj|��}tjj||trHdnd�}tj||�|S(ulMove 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.
    ucuo(	uimpucache_from_sourceuosupathudirnameuabspathujoinu	__debug__urename(usourceupyc_fileuup_oneu
legacy_pyc((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumake_legacy_pycEs

%umake_legacy_pyccCs�t|�xxtjD]m}tjj||d�}t|d�t|d�ttj|dd��ttj|dd��qWdS(u�'Forget' a module was ever imported.

    This removes the module from sys.modules and deletes any PEP 3147 or
    legacy .pyc and .pyo files.
    u.pyucuoudebug_overrideNTF(
uunloadusysupathuosujoinuunlinkuimpucache_from_sourceuTrueuFalse(umodnameudirnameusource((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuforgetUs
cCs�d}d}Gdd�dtj�}tjj}|j�}|sRtj��n|�}tjj�}|j||tj	|�tj
|�tj	|��}|s�tj��nt|j|@�S(NicBsG|EeZdZdejjfdejjfdejjfgZdS(u*_is_gui_available.<locals>.USEROBJECTFLAGSufInheritu	fReservedudwFlagsN(u__name__u
__module__u__qualname__uctypesuwintypesuBOOLuDWORDu_fields_(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuUSEROBJECTFLAGSmsuUSEROBJECTFLAGS(
uctypesu	Structureuwindlluuser32uGetProcessWindowStationuWinErroruwintypesuDWORDuGetUserObjectInformationWubyrefusizeofubooludwFlags(u	UOI_FLAGSuWSF_VISIBLEuUSEROBJECTFLAGSudlluhuuofuneededures((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_is_gui_availablejs"		u_is_gui_availablecCsdS(NT(uTrue(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_is_gui_available�scCstdk	o|tkS(uPTest whether a resource is enabled.  Known resources are set by
    regrtest.py.N(u
use_resourcesuNone(uresource((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuis_resource_enabled�scCs�|dkr(t�r(tjd��ntjd�jjd�dkrMdSt|�s�|dkrrd|}nt	|��ndS(u�Raise 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.
    uguiuCannot use the 'gui' resourceiu__name__u__main__Nu"Use of the %r resource not enabled(
u_is_gui_availableuunittestuSkipTestusysu	_getframeu	f_globalsugetuis_resource_enableduNoneuResourceDenied(uresourceumsg((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurequires�s!
cs��fdd�}|S(u�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
jd�||f��q�n�||�S(Nu-iiu.u(%s version %s or higher required, not %s(uplatformusystemureleaseusplitutupleumapuintu
ValueErrorujoinustruunittestuSkipTest(uargsukwuversion_txtuversionumin_version_txt(ufuncumin_versionusysname(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwrapper�s"
u:_requires_unix_version.<locals>.decorator.<locals>.wrapper(u	functoolsuwrapsumin_version(ufuncuwrapper(umin_versionusysname(ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decorator�s'	u)_requires_unix_version.<locals>.decorator((usysnameumin_versionu	decorator((umin_versionusysnameu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_requires_unix_version�su_requires_unix_versioncGs
td|�S(u�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.
    uFreeBSD(u_requires_unix_version(umin_version((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurequires_freebsd_version�scGs
td|�S(u�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.
    uLinux(u_requires_unix_version(umin_version((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurequires_linux_version�scs�fdd�}|S(u�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
jd||f��q�n�||�S(Nudarwiniu.u&Mac OS X %s or higher required, not %s(usysuplatformumac_verutupleumapuintusplitu
ValueErrorujoinustruunittestuSkipTest(uargsukwuversion_txtuversionumin_version_txt(ufuncumin_version(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwrapper�s"
u4requires_mac_ver.<locals>.decorator.<locals>.wrapper(u	functoolsuwrapsumin_version(ufuncuwrapper(umin_version(ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decorator�s$	u#requires_mac_ver.<locals>.decorator((umin_versionu	decorator((umin_versionu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurequires_mac_ver�su	127.0.0.1u::1cCs/tj||�}t|�}|j�~|S(u�
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.
    (usocketu	bind_portuclose(ufamilyusocktypeutempsockuport((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyufind_unused_port�s
8
c
Cs|jtjkr�|jtjkr�ttd�rc|jtjtj�dkrct	d��qcnttd�r�y1|jtjtj
�dkr�t	d��nWq�tk
r�Yq�Xnttd�r�|jtjtj
d�q�n|j|df�|j�d}|S(u%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.
    uSO_REUSEADDRiuHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!uSO_REUSEPORTuHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!uSO_EXCLUSIVEADDRUSEi(ufamilyusocketuAF_INETutypeuSOCK_STREAMuhasattru
getsockoptu
SOL_SOCKETuSO_REUSEADDRu
TestFaileduSO_REUSEPORTuOSErroru
setsockoptuSO_EXCLUSIVEADDRUSEubindugetsockname(usockuhostuport((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	bind_port's$
cCstjr{d}zRy-tjtjtj�}|jd�dSWntjtjfk
r_YnXWd|rw|j	�nXndS(u+Check whether IPv6 is enabled on this host.u::1iN(u::1iTF(usocketuhas_ipv6uNoneuAF_INET6uSOCK_STREAMubinduTrueuerrorugaierrorucloseuFalse(usock((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_is_ipv6_enabledLs	
	u_is_ipv6_enablediiiudoubleuIEEEutest requires IEEE 754 doublesu
requires zlibu
requires gzipurequires bz2u
requires lzmaujavau$testu@testu	{}_{}_tmpuæuİuŁuφuКuאu،uتuกu u€u-àòɘŁğudarwinuNFDuntuceiu-共Ł♡ͣ�utWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effectives�s-�usurrogateescapes�w�s���s�s��u-ccs�d}|dkr9tj�}d}tjj|�}nRytj|�d}Wn8t	k
r�|sl�nt
jd|tdd�YnXz	|VWd|r�t
j|�nXdS(u�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.

    u+tests may fail, unable to create temp dir: u
stackleveliNFT(uFalseuNoneutempfileumkdtempuTrueuosupathurealpathumkdiruOSErroruwarningsuwarnuRuntimeWarningushutilurmtree(upathuquietudir_created((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyutemp_dirs"



	utemp_dirccs|tj�}ytj|�Wn8tk
rW|s9�ntjd|tdd�YnXztj�VWdtj|�XdS(ugReturn 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.

    u)tests may fail, unable to change CWD to: u
stackleveliN(uosugetcwduchdiruOSErroruwarningsuwarnuRuntimeWarning(upathuquietu	saved_dir((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
change_cwd%s


u
change_cwdutempcwdccsBtd|d|��'}t|d|��}|VWdQXWdQXdS(u�
    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.

    upathuquietN(utemp_diru
change_cwd(unameuquietu	temp_pathucwd_dir((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyutemp_cwd@suumaskccs-tj|�}z	dVWdtj|�XdS(u8Context manager that temporarily sets the process umask.N(uosuumask(uumaskuoldmask((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
temp_umaskTs	udatacCs�tjj|�r|S|dk	r:tjj||�}ntgtj}x9|D]1}tjj||�}tjj|�rQ|SqQW|S(u[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(uosupathuisabsuNoneujoinu
TEST_HOME_DIRusysuexists(ufilenameusubdirupathudnufn((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyufindfilees
cCs4tj|tjtjBtjB�}tj|�dS(u>Create an empty file. If the file already exists, truncate it.N(uosuopenuO_WRONLYuO_CREATuO_TRUNCuclose(ufilenameufd((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucreate_empty_filews#cCs<t|j��}dd�|D�}dj|�}d|S(u%Like repr(dict), but in sorted order.cSsg|]}d|�qS(u%r: %r((u.0upair((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
<listcomp>s	usortdict.<locals>.<listcomp>u, u{%s}(usorteduitemsujoin(udictuitemsu	reprpairsu
withcommas((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyusortdict|scCs9ttd�}z|j�SWd|j�tt�XdS(u`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    uwbN(uopenuTESTFNufilenoucloseuunlink(ufile((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumake_bad_fd�s

umake_bad_fdcCs|jtt|dd�dS(Nu
<test string>uexec(uassertRaisesuSyntaxErrorucompile(utestcaseu	statement((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucheck_syntax_error�sc
szddl}ddl}�jdd��|jj|�djd�d}tjj	t
|�}���fdd�}tjj|�r�||�}|dk	r�|St|�nt
d�td	|d
t��|jj|dd�}zNt|d
��9}|j�}	x#|	r4|j|	�|j�}	qWWdQXWd|j�X||�}|dk	rf|Std|��dS(Niucheckiu/icsMt|���}�dkr"|S�|�r?|jd�|S|j�dS(Ni(uopenuNoneuseekuclose(ufnuf(uargsucheckukw(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucheck_valid_file�s
u*open_urlresource.<locals>.check_valid_fileuurlfetchu	fetching %s ...ufileutimeoutiuwbuinvalid resource %ri����(uurllib.requestuurllib.parseupopuNoneuparseuurlparseusplituosupathujoinu
TEST_DATA_DIRuexistsuunlinkurequiresuprintuget_original_stdouturequestuurlopenuopenureaduwriteucloseu
TestFailed(
uurluargsukwuurllibufilenameufnucheck_valid_fileufuoutus((uargsucheckukwu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuopen_urlresource�s0#	

	
cBsP|EeZdZdZdd�Zdd�Zedd��Zdd	�Zd
S(uWarningsRecorderuyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cCs||_d|_dS(Ni(u	_warningsu_last(uselfu
warnings_list((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__�s	uWarningsRecorder.__init__cCs\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS(Niu%r has no attribute %ri����(	ulenu	_warningsu_lastugetattruwarningsuWarningMessageu_WARNING_DETAILSuNoneuAttributeError(uselfuattr((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__getattr__�s
uWarningsRecorder.__getattr__cCs|j|jd�S(N(u	_warningsu_last(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwarnings�suWarningsRecorder.warningscCst|j�|_dS(N(ulenu	_warningsu_last(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyureset�suWarningsRecorder.resetN(	u__name__u
__module__u__qualname__u__doc__u__init__u__getattr__upropertyuwarningsureset(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuWarningsRecorder�s
uWarningsRecorderccsltjd�}|jjd�}|r4|j�ntjdd
��&}tjdj	d�t
|�VWdQXt|�}g}x�|D]�\}}d}	xg|dd�D]U}|j
}
tj|t|
�tj�r�t|
j|�r�d
}	|j|�q�q�W|	r�|r�|j||jf�q�q�W|rKtd|d��n|rhtd	|d��ndS(u�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.
    iu__warningregistry__urecorduwarningsualwaysNuunhandled warning %siu)filter (%r, %s) did not catch any warningTF(usysu	_getframeu	f_globalsugetuclearuwarningsucatch_warningsuTrueumodulesusimplefilteruWarningsRecorderulistuFalseumessageureumatchustruIu
issubclassu	__class__uremoveuappendu__name__uAssertionError(ufiltersuquietuframeuregistryuwureraiseumissingumsgucatuseenuwarning((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_filterwarnings�s0
	u_filterwarningscOsI|jd�}|s<dtff}|dkr<d}q<nt||�S(u�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)
    uquietuNT(ugetuWarninguNoneuTrueu_filterwarnings(ufiltersukwargsuquiet((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucheck_warnings�scBs>|EeZdZdZdd�Zdd�Zdd�ZdS(	uCleanImportu,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(usysumodulesucopyuoriginal_modulesu__name__(uselfumodule_namesumodule_nameumodule((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__!s

uCleanImport.__init__cCs|S(N((uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	__enter__.suCleanImport.__enter__cGstjj|j�dS(N(usysumodulesuupdateuoriginal_modules(uselfu
ignore_exc((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__exit__1suCleanImport.__exit__N(u__name__u
__module__u__qualname__u__doc__u__init__u	__enter__u__exit__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuCleanImports

cBs�|EeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS(uEnvironmentVarGuardu_Class to help protect the environment variable properly.  Can be used as
    a context manager.cCstj|_i|_dS(N(uosuenvironu_environu_changed(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__:suEnvironmentVarGuard.__init__cCs|j|S(N(u_environ(uselfuenvvar((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__getitem__>suEnvironmentVarGuard.__getitem__cCs<||jkr+|jj|�|j|<n||j|<dS(N(u_changedu_environuget(uselfuenvvaruvalue((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__setitem__AsuEnvironmentVarGuard.__setitem__cCsK||jkr+|jj|�|j|<n||jkrG|j|=ndS(N(u_changedu_environuget(uselfuenvvar((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__delitem__GsuEnvironmentVarGuard.__delitem__cCs
|jj�S(N(u_environukeys(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyukeysNsuEnvironmentVarGuard.keyscCs
t|j�S(N(uiteru_environ(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__iter__QsuEnvironmentVarGuard.__iter__cCs
t|j�S(N(ulenu_environ(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__len__TsuEnvironmentVarGuard.__len__cCs|||<dS(N((uselfuenvvaruvalue((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyusetWsuEnvironmentVarGuard.setcCs||=dS(N((uselfuenvvar((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuunsetZsuEnvironmentVarGuard.unsetcCs|S(N((uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	__enter__]suEnvironmentVarGuard.__enter__cGshxU|jj�D]D\}}|dkrG||jkrT|j|=qTq||j|<qW|jt_dS(N(u_changeduitemsuNoneu_environuosuenviron(uselfu
ignore_excukuv((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__exit__`suEnvironmentVarGuard.__exit__N(u__name__u
__module__u__qualname__u__doc__u__init__u__getitem__u__setitem__u__delitem__ukeysu__iter__u__len__usetuunsetu	__enter__u__exit__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuEnvironmentVarGuard5scBs>|EeZdZdZdd�Zdd�Zdd�ZdS(	u
DirsOnSysPathu�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.
    cGs6tjdd�|_tj|_tjj|�dS(N(usysupathuoriginal_valueuoriginal_objectuextend(uselfupaths((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__vsuDirsOnSysPath.__init__cCs|S(N((uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	__enter__{suDirsOnSysPath.__enter__cGs&|jt_|jtjdd�<dS(N(uoriginal_objectusysupathuoriginal_value(uselfu
ignore_exc((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__exit__~suDirsOnSysPath.__exit__N(u__name__u
__module__u__qualname__u__doc__u__init__u	__enter__u__exit__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
DirsOnSysPathjs
u
DirsOnSysPathcBsG|EeZdZdZdd�Zdd�Zddddd�ZdS(	uTransientResourceu�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cKs||_||_dS(N(uexcuattrs(uselfuexcukwargs((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__�s	uTransientResource.__init__cCs|S(N((uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	__enter__�suTransientResource.__enter__cCs}|dk	ryt|j|�ryxX|jj�D]8\}}t||�sMPnt||�|kr.Pq.q.Wtd��ndS(u�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).u%an optional resource is not availableN(uNoneu
issubclassuexcuattrsuitemsuhasattrugetattruResourceDenied(uselfutype_uvalueu	tracebackuattru
attr_value((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__exit__�suTransientResource.__exit__N(u__name__u
__module__u__qualname__u__doc__u__init__u	__enter__uNoneu__exit__(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuTransientResource�suerrnoutimeoutg>@uerrnosc	#s�ddd d!d"g}d$d&d(d*d+g}td|��|�g��sudd�|D��dd�|D��n���fdd�}tj�}z�y%|dk	r�tj|�ndVWn�tk
ri}z�xq|j}t|�dkrt|dt�r|d}q�t|�dkrFt|dt�rF|d}q�Pq�||��WYdd}~XnXWdtj|�XdS(,u�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.uECONNREFUSEDiou
ECONNRESETihuEHOSTUNREACHiquENETUNREACHieu	ETIMEDOUTinu	EAI_AGAINiuEAI_FAILiu
EAI_NONAMEiu
EAI_NODATAiu
WSANO_DATAi�*uResource %r is not availablecSs(g|]\}}tt||��qS((ugetattruerrno(u.0unameunum((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
<listcomp>�s	u&transient_internet.<locals>.<listcomp>cSs(g|]\}}tt||��qS((ugetattrusocket(u.0unameunum((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
<listcomp>�s	cs�t|dd�}t|tj�sNt|tj�rB|�ksN|�kr~tsrtjj	�j
dd�n�|�ndS(Nuerrnoiu
(ugetattruNoneu
isinstanceusocketutimeoutugaierroruverboseusysustderruwriteuargs(uerrun(ucaptured_errnosudeniedu
gai_errnos(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyufilter_error�su(transient_internet.<locals>.filter_errorNii(uECONNREFUSEDio(u
ECONNRESETih(uEHOSTUNREACHiq(uENETUNREACHie(u	ETIMEDOUTini����(u	EAI_AGAINi����i����(uEAI_FAILi����i����(u
EAI_NONAMEi����i����(u
EAI_NODATAi����(u
WSANO_DATAi�*(	uResourceDeniedusocketugetdefaulttimeoutuNoneusetdefaulttimeoutuIOErroruargsulenu
isinstance(	u
resource_nameutimeoutuerrnosudefault_errnosudefault_gai_errnosufilter_erroruold_timeoutuerrua((ucaptured_errnosudeniedu
gai_errnosu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyutransient_internet�sF			
	
			%
%

c
cs[ddl}tt|�}tt||j��ztt|�VWdtt||�XdS(u�Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.iN(uiougetattrusysusetattruStringIO(ustream_nameuiouorig_stdout((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucaptured_output�sucaptured_outputcCs
td�S(u�Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print("hello")
       self.assertEqual(stdout.getvalue(), "hello
")
    ustdout(ucaptured_output(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucaptured_stdout�scCs
td�S(u�Capture the output of sys.stderr:

       with captured_stderr() as stderr:
           print("hello", file=sys.stderr)
       self.assertEqual(stderr.getvalue(), "hello
")
    ustderr(ucaptured_output(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucaptured_stderr�scCs
td�S(uCapture the input to sys.stdin:

       with captured_stdin() as stdin:
           stdin.write('hello
')
           stdin.seek(0)
           # call test code that consumes from sys.stdin
           captured = input()
       self.assertEqual(captured, "hello")
    ustdin(ucaptured_output(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucaptured_stdins
cCs8tj�tr tjd�ntj�tj�dS(u�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(ugcucollectu	is_jythonutimeusleep(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
gc_collects



u
gc_collectc
cs:tj�}tj�z	dVWd|r5tj�nXdS(N(ugcu	isenabledudisableuenable(uhave_gc((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
disable_gc s
	u
disable_gccCs`tjd�pd}d}x,|j�D]}|jd�r(|}q(q(W|dko_|dkS(u,Find if Python was built with optimizations.u	PY_CFLAGSuu-Ou-O0(u	sysconfiguget_config_varusplitu
startswith(ucflagsu	final_optuopt((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyupython_is_optimized+s
upython_is_optimizedunPu0nugettotalrefcountu2Pu0PuncCstjt|t�S(N(ustructucalcsizeu_headeru_align(ufmt((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucalcobjsize<sucalcobjsizecCstjt|t�S(N(ustructucalcsizeu_vheaderu_align(ufmt((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucalcvobjsize?sucalcvobjsizeii	cCs�ddl}tj|�}t|�tkr:|jt@s_t|�tkrot|�jt@ro||j7}ndt|�||f}|j|||�dS(Niu&wrong size for %s: got %d, expected %d(	u	_testcapiusysu	getsizeofutypeu	__flags__u_TPFLAGS_HEAPTYPEu_TPFLAGS_HAVE_GCuSIZEOF_PYGC_HEADuassertEqual(utestuousizeu	_testcapiuresultumsg((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucheck_sizeofFs%ucheck_sizeofcs��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(Ni(ulocaleugetattru	setlocaleuAttributeErroruNone(uargsukwdsulocaleucategoryuorig_localeuloc(ucatstrufunculocales(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuinnerWs$

	u1run_with_locale.<locals>.decorator.<locals>.inner(u__name__u__doc__(ufuncuinner(ucatstrulocales(ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decoratorVsu"run_with_locale.<locals>.decorator((ucatstrulocalesu	decorator((ucatstrulocalesu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurun_with_localeUscs�fdd�}|S(Ncs1��fdd�}�j|_�j|_|S(Ncs�y
tj}Wn!tk
r0tjd��YnXdtjkrPtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS(Nutzset requireduTZ(utimeutzsetuAttributeErroruunittestuSkipTestuosuenvironuNone(uargsukwdsutzsetuorig_tz(ufuncutz(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuinner{s




u-run_with_tz.<locals>.decorator.<locals>.inner(u__name__u__doc__(ufuncuinner(utz(ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decoratorzsurun_with_tz.<locals>.decorator((utzu	decorator((utzu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurun_with_tzyscCs�idd6td6td6dtd6}tjd|tjtjB�}|dkrgtd|f��ntt	|j
d��||j
d	�j��}|a|t
kr�t
}n|tdkr�td
|f��n|adS(Niukumugutu(\d+(\.\d+)?) (K|M|G|T)b?$uInvalid memory limit %riiu$Memory limit %r too low to be useful(u_1Mu_1Gureumatchu
IGNORECASEuVERBOSEuNoneu
ValueErroruintufloatugroupulowerureal_max_memuseuMAX_Py_ssize_tu_2Gu
max_memuse(ulimitusizesumumemlimit((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuset_memlimit�s 2	cBs>|EeZdZdZdd�Zdd�Zdd�ZdS(	u_MemoryWatchdogu`An object which periodically watches the process' memory consumption
    and prints it out.
    cCs(djdtj��|_d|_dS(Nu/proc/{pid}/statmupidF(uformatuosugetpiduprocfileuFalseustarted(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__�su_MemoryWatchdog.__init__cCs�yt|jd�}WnOtk
rg}z/tjdj|�t�tjj	�dSWYdd}~XnXt
d�}tjtj
|gd|dtj�|_|j�d|_dS(Nuru!/proc not available for stats: {}umemory_watchdog.pyustdinustderrT(uopenuprocfileuOSErroruwarningsuwarnuformatuRuntimeWarningusysustderruflushufindfileu
subprocessuPopenu
executableuDEVNULLumem_watchdogucloseuTrueustarted(uselfufueuwatchdog_script((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyustart�s

u_MemoryWatchdog.startcCs*|jr&|jj�|jj�ndS(N(ustartedumem_watchdogu	terminateuwait(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyustop�s	
u_MemoryWatchdog.stopN(u__name__u
__module__u__qualname__u__doc__u__init__ustartustop(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_MemoryWatchdog�su_MemoryWatchdogcs���fdd�}|S(uADecorator 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(	Niu'not enough memory: %.1fG minimum needediiu* ... expected peak memory use: {peak:.1f}Gupeaki@i@(usizeumemuseureal_max_memuseuunittestuSkipTestuverboseuprintuformatu_MemoryWatchdogustartuNoneustop(uselfusizeumemuseumaxsizeuwatchdog(udry_runufuwrapper(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwrapper�s*			
	
u.bigmemtest.<locals>.decorator.<locals>.wrapper(usizeumemuse(uf(udry_runumemuseusize(ufuwrapperu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decorator�s		ubigmemtest.<locals>.decorator((usizeumemuseudry_runu	decorator((udry_runumemuseusizeu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
bigmemtest�s
!cs�fdd�}|S(u0Decorator for tests that fill the address space.cs^ttkrPtd
kr6tdkr6tjd��qZtjdtd��n
�|�SdS(
Nii?iiu-not enough memory: try a 32-bit build insteadu'not enough memory: %.1fG minimum needediill����li@(u
max_memuseuMAX_Py_ssize_tuunittestuSkipTest(uself(uf(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwrappersu!bigaddrspacetest.<locals>.wrapper((ufuwrapper((ufu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyubigaddrspacetestscBs |EeZdZdd�ZdS(uBasicTestRunnercCstj�}||�|S(N(uunittestu
TestResult(uselfutesturesult((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuruns
uBasicTestRunner.runN(u__name__u
__module__u__qualname__urun(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuBasicTestRunnerscCs|S(N((uobj((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu_idsu_idcCsM|dkr#t�r#tjd�St|�r3tStjdj|��SdS(Nuguiuresource 'gui' is not availableuresource {0!r} is not enabled(u_is_gui_availableuunittestuskipuis_resource_enabledu_iduformat(uresource((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurequires_resources

urequires_resourcecCstdd�|�S(u9
    Decorator for tests only applicable on CPython.
    ucpythonT(uimpl_detailuTrue(utest((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucpython_only&scKs}t|�rtS|dkrpt|�\}}|r=d}nd}t|j��}|jdj|��}ntj	|�S(Nu*implementation detail not available on {0}u%implementation detail specific to {0}u or (
ucheck_impl_detailu_iduNoneu
_parse_guardsusortedukeysuformatujoinuunittestuskip(umsguguardsu
guardnamesudefault((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuimpl_detail,s	uimpl_detailcCsc|sidd6dfSt|j��d}t|j��|gt|�ksXt�||fS(NucpythoniTF(uTrueuFalseulistuvaluesulenuAssertionError(uguardsuis_true((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
_parse_guards9s
+u
_parse_guardscKs.t|�\}}|jtj�j�|�S(u5This 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
    (u
_parse_guardsugetuplatformupython_implementationulower(uguardsudefault((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucheck_impl_detailCscs<ttd�s�Stj���fdd��}|SdS(uEDecorator to temporarily turn off tracing for the duration of a test.ugettracecs?tj�}ztjd��||�SWdtj|�XdS(N(usysugettraceusettraceuNone(uargsukwargsuoriginal_trace(ufunc(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuwrapperSs

uno_tracing.<locals>.wrapperN(uhasattrusysu	functoolsuwraps(ufuncuwrapper((ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
no_tracingNs!u
no_tracingcCstt|��S(uDecorator 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.

    (u
no_tracingucpython_only(utest((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
refcount_test^su
refcount_testcCsrg}x\|jD]Q}t|tj�rEt||�|j|�q||�r|j|�qqW||_dS(u>Recursively filter test cases in a suite based on a predicate.N(u_testsu
isinstanceuunittestu	TestSuiteu
_filter_suiteuappend(usuiteupredunewtestsutest((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
_filter_suiteis
u
_filter_suitecCs�tr'tjtjdddt�}n	t�}|j|�}|j�s�t	|j
�dkr~|jr~|j
dd}nLt	|j�dkr�|j
r�|jdd}nd}ts�|d7}nt|��ndS(	u2Run tests from a unittest.TestSuite-derived class.u	verbosityiufailfastiiumultiple errors occurredu!; run in verbose mode for detailsN(
uverboseuunittestuTextTestRunnerusysustdoutufailfastuBasicTestRunnerurunu
wasSuccessfululenuerrorsufailuresu
TestFailed(usuiteurunneruresultuerr((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
_run_suiteus	
u
_run_suitecGs�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wdd�}t||�t|�dS(u1Run tests from unittest.TestCase-derived classes.u)str arguments must be keys in sys.modulescSsJtdkrdSx3|j�jd�D]}tj|t�r&dSq&WdS(Nu.TF(umatch_testsuNoneuTrueuidusplitufnmatchufnmatchcaseuFalse(utestuname((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	case_pred�surun_unittest.<locals>.case_predN(
uunittestu	TestSuiteuTestCaseu
isinstanceustrusysumodulesuaddTestu
findTestCasesu
ValueErroru	makeSuiteu
_filter_suiteu
_run_suite(uclassesuvalid_typesusuiteuclsu	case_pred((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurun_unittest�s
 
ucpythonuwin32uWITH_DOC_STRINGSutest requires docstringscCs�ddl}|dkr!t}nd}|j|d|d|�\}}|rgtd||f��ntr�td|j|f�n||fS(uRun 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).
    iNuverboseuoptionflagsu%d of %d doctests failedu,doctest (%s) ... %d tests with zero failures(udoctestuNoneuverboseutestmodu
TestFaileduprintu__name__(umoduleu	verbosityuoptionflagsudoctestufut((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyurun_doctest�s	!cCstjj�fS(N(usysumodulesucopy(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
modules_setup�su
modules_setupcCsMdd�tjj�D�}tjj�tjj|�tjj|�dS(NcSs1g|]'\}}|jd�r||f�qS(u
encodings.(u
startswith(u.0ukuv((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
<listcomp>�s		u#modules_cleanup.<locals>.<listcomp>(usysumodulesuitemsuclearuupdate(u
oldmodulesu	encodings((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumodules_cleanup�s
umodules_cleanupcCs-trtj�tjj�fSdffSdS(Ni(u_threadu_countu	threadingu	_danglingucopy(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuthreading_setup�scGsdts
dSd}xMt|�D]?}tj�tjf}||krHPntjd�t�qWdS(Ni
g�������?(u_threadurangeu_countu	threadingu	_danglingutimeusleepu
gc_collect(uoriginal_valuesu
_MAX_COUNTucountuvalues((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuthreading_cleanup�s
cs/ts
�Stj���fdd��}|S(u�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(uthreading_setuputhreading_cleanup(uargsukey(ufunc(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	decorators	ureap_threads.<locals>.decorator(u_threadu	functoolsuwraps(ufuncu	decorator((ufuncu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyureap_threads�s!ureap_threadsc	Cs]ttd�rYd}xAy/tj|tj�\}}|dkrFPnWqPYqXqndS(u�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.
    uwaitpidiiNi����(uhasattruosuwaitpiduWNOHANG(uany_processupidustatus((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu
reap_childrens	c
cs|t||�rNt||�}t|||�z	dVWdt|||�Xn*t|||�z	dVWdt||�XdS(umTemporary 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(uhasattrugetattrusetattrudelattr(uobjuattrunew_valureal_val((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	swap_attrs
		ccs\||kr:||}|||<z	dVWd|||<Xn|||<z	dVWd||=XdS(ukTemporary 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.
    N((uobjuitemunew_valureal_val((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	swap_item:s


	
	cCstjdd|�j�}|S(u�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?s(ureusubustrip(ustderr((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyustrip_python_stderrUsustrip_python_stderrcCs
tj�S(unReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.(u
subprocessu_args_from_interpreter_flags(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuargs_from_interpreter_flags_suargs_from_interpreter_flagscBsD|EeZdZdd�Zdd�Zdd�Zdd�Zd	S(
uTestHandlercCs#tjjj|d�||_dS(Ni(ulogginguhandlersuBufferingHandleru__init__umatcher(uselfumatcher((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu__init__isuTestHandler.__init__cCsdS(NF(uFalse(uself((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyushouldFlushrsuTestHandler.shouldFlushcCs$|j|�|jj|j�dS(N(uformatubufferuappendu__dict__(uselfurecord((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuemitus
uTestHandler.emitcKs=d}x0|jD]%}|jj||�rd}PqqW|S(uW
        Look for a saved dict whose keys/values match the supplied arguments.
        FT(uFalseubufferumatcherumatchesuTrue(uselfukwargsuresultud((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumatchesysuTestHandler.matchesN(u__name__u
__module__u__qualname__u__init__ushouldFlushuemitumatches(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuTestHandlerhs	cBs2|EeZdZdZdd�Zdd�ZdS(	uMatcherumsgumessagecKsSd}xF|D]>}||}|j|�}|j|||�s
d}Pq
q
W|S(u.
        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(uTrueugetumatch_valueuFalse(uselfudukwargsuresultukuvudv((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumatches�s

uMatcher.matchescCsjt|�t|�kr!d}nEt|�tk	sB||jkrQ||k}n|j|�dk}|S(uT
        Try to match a single stored value (dv) with a supplied value (v).
        iF(utypeuFalseustru_partial_matchesufind(uselfukudvuvuresult((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyumatch_value�s	!uMatcher.match_valueN(umsgumessage(u__name__u
__module__u__qualname__u_partial_matchesumatchesumatch_value(u
__locals__((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuMatcher�sc
Csotdk	rtStd}ytjt|�d}Wn!tttfk
rWd}YnXtj
|�|a|S(Nucan_symlinkTF(u_can_symlinkuNoneuTESTFNuosusymlinkuTrueuOSErroruNotImplementedErroruAttributeErroruFalseuremove(usymlink_pathucan((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucan_symlink�s


cCs,t�}d}|r|Stj|�|�S(u8Skip decorator for tests that require functional symlinku*Requires functional symlink implementation(ucan_symlinkuunittestuskip(utestuokumsg((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuskip_unless_symlink�s	cCstdk	rtSttd�s(d}n�tj�\}}z�ttd���}yutj	|dd�tj	|j
�dd�tj�}t
jd|�}|dkp�t|jd��dk}Wntk
r�d}YnXWdQXWdtt�t|�X|a|S(	Nusetxattruwbs	user.testsu
2.6.(\d{1,2})ii'F(u
_can_xattruNoneuhasattruosuFalseutempfileumkstempuopenuTESTFNusetxattrufilenouplatformureleaseureumatchuintugroupuOSErroruunlink(ucanutmp_fputmp_nameufpukernel_versionum((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu	can_xattr�s&	+

u	can_xattrcCs,t�}d}|r|Stj|�|�S(uDSkip decorator for tests that require functional extended attributesu(no non-broken extended attribute support(u	can_xattruunittestuskip(utestuokumsg((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyuskip_unless_xattr�s	ccs\ddl}|jj}d}|j|�}|j||B�z	dVWd|j|�XdS(u;Disable Windows Error Reporting dialogs using SetErrorMode.iNi(uctypesuwindllukernel32uSetErrorMode(uctypesuk32uSEM_NOGPFAULTERRORBOXuold_error_mode((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyusuppress_crash_popup�s	ccs	dVdS(N((((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyusuppress_crash_popup�scs�t���d�y�j��Wn*ttfk
rPt��d��YnXd�����fdd�}|j|�t��|�dS(u�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'.

    cs*�rt����n
t���dS(N(usetattrudelattr((u
attr_is_localu	attr_nameuobject_to_patchu	old_value(u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyucleanupsupatch.<locals>.cleanupNFT(	ugetattruFalseu__dict__uAttributeErroruKeyErroruNoneuTrueu
addCleanupusetattr(u
test_instanceuobject_to_patchu	attr_nameu	new_valueucleanup((u
attr_is_localu	attr_nameuobject_to_patchu	old_valueu:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyupatch�s


upatchTFii@i@i@ii(uæuİuŁuφuКuאu،uتuกu u€(untuce(s�w�s�s���s�s��i@ii(�u__doc__u__name__uImportErroru
contextlibuerrnou	functoolsugcusocketusysuosuplatformushutiluwarningsuunittestu	importlibucollections.abcucollectionsureu
subprocessuimputimeu	sysconfigufnmatchulogging.handlersuloggingustructutempfileu_threadu	threadinguNoneumultiprocessing.processumultiprocessinguzlibugzipubz2ulzmau__all__u	ExceptionuErroru
TestFaileduSkipTestuResourceDenieducontextmanageruTrueu_ignore_deprecated_importsuFalseu
import_moduleu_save_and_remove_moduleu_save_and_block_moduleuanticipate_failureuimport_fresh_moduleu
get_attributeuverboseu
use_resourcesu
max_memuseureal_max_memuseufailfastumatch_testsu_original_stdouturecord_original_stdoutuget_original_stdoutuunloadu
startswithu_waitforu_unlinku_rmdiru_rmtreeuunlinkurmdirurmtreeumake_legacy_pycuforgetuctypesuctypes.wintypesu_is_gui_availableuis_resource_enabledurequiresu_requires_unix_versionurequires_freebsd_versionurequires_linux_versionurequires_mac_veruHOSTuHOSTv6uAF_INETuSOCK_STREAMufind_unused_portu	bind_portu_is_ipv6_enableduIPV6_ENABLEDu
PIPE_MAX_SIZEu
SOCK_MAX_SIZEu
skipUnlessufloatu
__getformat__urequires_IEEE_754u
requires_zlibu
requires_gzipurequires_bz2u
requires_lzmau	is_jythonunameuTESTFNuformatugetpiduFS_NONASCIIu	characterufsdecodeufsencodeuUnicodeErroruTESTFN_UNICODEuunicodedatau	normalizeugetfilesystemencodinguTESTFN_ENCODINGuTESTFN_UNENCODABLEugetwindowsversionuencodeuUnicodeEncodeErroruprintudecodeuUnicodeDecodeErroruTESTFN_UNDECODABLEuTESTFN_NONASCIIugetcwduSAVEDCWDutemp_diru
change_cwdutemp_cwduhasattru
temp_umaskupathudirnameuabspathu__file__uTEST_SUPPORT_DIRu
TEST_HOME_DIRujoinu
TEST_DATA_DIRufindfileucreate_empty_fileusortdictumake_bad_fducheck_syntax_erroruopen_urlresourceuobjectuWarningsRecorderu_filterwarningsucheck_warningsuCleanImportuabcuMutableMappinguEnvironmentVarGuardu
DirsOnSysPathuTransientResourceuIOErroru	ETIMEDOUTutime_outuerroru
ECONNRESETusocket_peer_resetuioerror_peer_resetutransient_internetucaptured_outputucaptured_stdoutucaptured_stderrucaptured_stdinu
gc_collectu
disable_gcupython_is_optimizedu_headeru_alignu_vheaderucalcobjsizeucalcvobjsizeu_TPFLAGS_HAVE_GCu_TPFLAGS_HEAPTYPEucheck_sizeofurun_with_localeurun_with_tzu_1Mu_1Gu_2Gu_4GumaxsizeuMAX_Py_ssize_tuset_memlimitu_MemoryWatchdogu
bigmemtestubigaddrspacetestuBasicTestRunneru_idurequires_resourceucpython_onlyuimpl_detailu
_parse_guardsucheck_impl_detailu
no_tracingu
refcount_testu
_filter_suiteu
_run_suiteurun_unittestuget_config_varuHAVE_DOCSTRINGSurequires_docstringsurun_doctestu
modules_setupumodules_cleanuputhreading_setuputhreading_cleanupureap_threadsu
reap_childrenu	swap_attru	swap_itemustrip_python_stderruargs_from_interpreter_flagsuhandlersuBufferingHandleruTestHandleruMatcheru_can_symlinkucan_symlinkuskip_unless_symlinku
_can_xattru	can_xattruskip_unless_xattrusuppress_crash_popupupatch(((u:/opt/alt/python33/lib64/python3.3/test/support/__init__.pyu<module>sB





						
2	!					>%			








!,' 5	@		


	
$#


	-

		
	"