%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/future/backports/test/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyo

�
�A�[cJ@`s�
dZddlmZmZmZmZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZeed�sddlZnddlZddlZddlZddlZddl Z yddl!Z!Wn!e"k
rwddl#m!Z!nXddl$Z$ddl%Z&ddl'Z'ddl(Z(y@ej)r�ddl*Z*ddl+Z+nddl,Z*ddl+Z+Wne"k
rdZ*dZ+nXyddl.Z/Wne"k
r1dZ/nXyddl0Z0Wne"k
r[dZ0nXyddl1Z1Wne"k
r�dZ1nXyddl2Z2Wne"k
r�dZ2nXyddl3Z3Wne"k
r�dZ3nXdd	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@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQgJZ4dRe5fdS��YZ6dTe6fdU��YZ7dVej8fdW��YZ9ej:e;dX��Z<e=dY�Z>dZ�Z?d[�Z@d\�ZAd�d�e=d]�ZBd^�ZCd_ZDdZEdaFdaGe=ZHdZIdaJd`�ZKda�ZLdb�ZMejjNdc�r�e=dd�ZOde�ZPdf�ZQdg�ZRnejSZPejTZQejUZRdh�ZSdi�ZTdj�ZUdk�ZVdl�ZWejjNdc�rYddlXZXddlYZXdm�ZZn	dn�ZZdo�Z[ddp�Z\dq�Z]dr�Z^ds�Z_dt�Z`duZadvZbejcejddw�Zeeadx�Zfdy�Zgeg�Zhd�Zid�Zjejke0d}�Zlejke2d~�Zmejke3d�ZnejjNd��Zoejpd�krFd�Zqnd�Zqd�jreqejs��Zqejt�Zuej:d�e=dd���Zveed��r�ej:d���Zwnexdd��Zyd��Zzd��Z{d��Z|d��Z}d��Z~d�efd���YZ�e=d��Z�ej:d���Z�d�efd���YZ�ej)rYddl�Z�e�j�j�Z�nddl�Z�e�j�Z�d�e�fd���YZ�d�efd���YZ�d�efd���YZ�e�e�d�ej��Z�e�ej�d�ej��Z�e�e�d�ej��Z�ej:d�d�d���Z�ej:d���Z�d��Z�d��Z�d��Z�d��Z�ej:d���Z�d��Z�d�Z�d�Z�eed��r�d�e�Z�d�Z�ne�d�Z�d��Z�d��Z�d�Z�d�Z�d��Z�d��Z�d��Z�d�Z�d{e�Z�d�e�Z�dze�Z�ej�Z�d��Z�d�efd���YZ�e;d��Z�d��Z�d�efd���YZ�d��Z�d��Z�d��Z�dd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�ddd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�ej:d���Z�ej:d���Z�d��Z�d��Z�d�e&j�j�fd���YZ�d�efd���YZ�da�d��Z�d��Z�da�d��Z�d��Z�ejjNdc�r�
ej:d���Z�nej:d���Z�d��Z�dS(�uwSupporting definitions for the Python regression tests.

Backported for python-future from Python 3.3 test/support.py.
i(tabsolute_importtdivisiontprint_functiontunicode_literals(tutils(tstrtrangetopentinttmaptlistNuskip(t	sysconfiguErroru
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_popuptErrorcB`seZdZRS(u*Base class for regression test exceptions.(t__name__t
__module__t__doc__(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRbst
TestFailedcB`seZdZRS(uTest failed.(R
RR(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRestResourceDeniedcB`seZdZRS(u�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.
    (R
RR(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRhscc`s=|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(twarningstcatch_warningstfilterwarningstDeprecationWarning(tignore((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_ignore_deprecated_importsps
c	C`sSt|��Aytj|�SWn(tk
rH}tjt|���nXWdQXdS(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(Rt	importlibt
import_moduletImportErrortunittesttSkipTestR(tnamet
deprecatedtmsg((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRs

cC`s�|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(tsystmodulest
__import__R
t
startswith(Rtorig_modulestmodname((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_save_and_remove_module�s

cC`sFt}ytj|||<Wntk
r4t}nXdtj|<|S(u�Helper function to save and block a module in sys.modules

    Return True if the module was in sys.modules, False otherwise.
    N(tTrueR R!tKeyErrortFalsetNone(RR$tsaved((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_save_and_block_module�s


cC`s|r
tjSd�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.
    cS`s|S(N((tf((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt<lambda>�t(RtexpectedFailure(t	condition((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytanticipate_failure�scC`s�t|���i}g}t||�zyax|D]}t||�q3Wx-|D]%}t||�sQ|j|�qQqQWtj|�}Wntk
r�d}nXWdx'|j�D]\}	}
|
t	j
|	<q�Wx|D]}t	j
|=q�WX|SWdQXdS(uVImport 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.

    If deprecated is True, any module or package deprecation messages
    will be suppressed.
    N(RR&R,tappendRRRR*titemsR R!(RtfreshtblockedRR$tnames_to_removet
fresh_nametblocked_nametfresh_modulet	orig_nametmoduletname_to_remove((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytimport_fresh_module�s&





cC`sHyt||�}Wn*tk
r?tjd||f��nX|SdS(u?Get an attribute, raising SkipTest if AttributeError is raised.uobject %r has no attribute %rN(tgetattrtAttributeErrorRR(tobjRt	attribute((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
get_attribute�s

icC`s
|adS(N(t_original_stdout(tstdout((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrecord_original_stdout�scC`s
tptjS(N(RDR RE(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytget_original_stdoutscC`s&ytj|=Wntk
r!nXdS(N(R R!R((R((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytunloads
uwincC`s�||�|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 t
stackleveli(	tostpathtsplittlistdirttimetsleepRtwarntRuntimeWarning(tfunctpathnametwaitalltdirnameRttimeouttL((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_waitfor
s
	

cC`sttj|�dS(N(RXRJtunlink(tfilename((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_unlink+scC`sttj|�dS(N(RXRJtrmdir(RU((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_rmdir.sc`s6�fd��t�|dt�ttj|�dS(Nc`suxntj|�D]]}tjj||�}tjj|�r`t�|dt�tj|�qtj|�qWdS(NRT(	RJRMRKtjointisdirRXR'R\RY(RKRtfullname(t
_rmtree_inner(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRa2sRT(RXR'RJR\(RK((RasN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_rmtree1scC`sIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(R[tOSErrorterrnotENOENTtENOTDIR(RZterror((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRYAs
cC`s@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(R]RcRdRe(RURg((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR\Is
cC`s@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(RbRcRdRe(RKRg((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrmtreeQs
cC`sftj|�}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(	timptcache_from_sourceRJRKRUtabspathR^t	__debug__trename(tsourcetpyc_filetup_onet
legacy_pyc((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytmake_legacy_pycXs

%cC`s�t|�xxtjD]m}tjj||d�}t|d�t|d�ttj|dt��ttj|dt	��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.pyucuotdebug_overrideN(
RHR RKRJR^RYRiRjR'R)(R%RURn((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytforgeths
cC`s�d}d}dtjfd��Y}tjj}|j�}|sRtj��n|�}tjj�}|j||tj	|�tj
|�tj	|��}|s�tj��nt|j|@�S(NitUSEROBJECTFLAGScB`s;eZdejjfdejjfdejjfgZRS(ufInheritu	fReservedudwFlags(R
RtctypestwintypestBOOLtDWORDt_fields_(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRu�s(
Rvt	Structuretwindlltuser32tGetProcessWindowStationtWinErrorRwRytGetUserObjectInformationWtbyreftsizeoftbooltdwFlags(t	UOI_FLAGStWSF_VISIBLERutdllthtuoftneededtres((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_is_gui_available}s"		cC`stS(N(R'(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��scC`stdk	o|tkS(uPTest whether a resource is enabled.  Known resources are set by
    regrtest.py.N(t
use_resourcesR*(tresource((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytis_resource_enabled�scC`s�|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(
R�RRR t	_getframet	f_globalstgetR�R*R(R�R((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrequires�s!
c`s��fd�}|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.
    c`s1tj�����fd��}�|_|S(Nc`s�tj��kr�tj�jdd�d}y"ttt|jd���}Wntk
rcq�X|�kr�djtt	���}t
jd�||f��q�n�||�S(Nu-iiu.u(%s version %s or higher required, not %s(tplatformtsystemtreleaseRLttupleR	Rt
ValueErrorR^RRR(targstkwtversion_txttversiontmin_version_txt(RRtmin_versiontsysname(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytwrapper�s"
(t	functoolstwrapsR�(RRR�(R�R�(RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	decorator�s$	((R�R�R�((R�R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_requires_unix_version�scG`s
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(R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrequires_freebsd_version�scG`s
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(R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrequires_linux_version�sc`s�fd�}|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.
    c`s.tj����fd��}�|_|S(Nc`s�tjdkr�tj�d}y"ttt|jd���}Wntk
rTq�X|�kr�djtt	���}t
jd||f��q�n�||�S(Nudarwiniu.u&Mac OS X %s or higher required, not %s(R R�tmac_verR�R	RRLR�R^RRR(R�R�R�R�R�(RRR�(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s"
(R�R�R�(RRR�(R�(RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s!	((R�R�((R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrequires_mac_ver�su	127.0.0.1u::1cC`s/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.
    (tsockett	bind_porttclose(tfamilytsocktypettempsocktport((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytfind_unused_port�s
8
cC`s|jtjkr�|jtjkr�ttd�rc|jtjtj�dkrct	d��qcnttd�r�y1|jtjtj
�dkr�t	d��nWq�tjk
r�q�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(R�R�tAF_INETttypetSOCK_STREAMthasattrt
getsockoptt
SOL_SOCKETtSO_REUSEADDRRtSO_REUSEPORTRgt
setsockopttSO_EXCLUSIVEADDRUSEtbindtgetsockname(tsockthostR�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�9s$cC`s~tjrzd}zQy-tjtjtj�}|jd�tSWntjtjfk
r^nXWd|rv|j	�nXnt
S(u+Check whether IPv6 is enabled on this host.u::1iN(u::1i(R�thas_ipv6R*tAF_INET6R�R�R'RgtgaierrorR�R)(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_is_ipv6_enabled^s	
iiiu
requires zliburequires bz2u
requires lzmaujavau$testu@testu{0}_{1}_tmputempcwdcc`s�tj�}t}|dkrx|}ytj|�t}Wqxtk
rt|sW�ntjd|t	dd�qxXnytj
|�Wn7tk
r�|s��ntjd|t	dd�nXztj�VWdtj
|�|r�t|�nXdS(u�
    Context manager that temporarily changes the CWD.

    An existing path may be provided as *path*, in which case this
    function makes no changes to the file system.

    Otherwise, the new CWD is created in the current directory and it's
    named *name*. If *quiet* is False (default) and it's not possible to
    create or change the CWD, an error is raised.  If it's True, only a
    warning is raised and the original CWD is used.
    u*tests may fail, unable to create temp CWD RIiu,tests may fail, unable to change the CWD to N(RJtgetcwdR)R*tmkdirR'RcRRPRQtchdirRh(RtquietRKt	saved_dirtis_temporary((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyttemp_cwds0







uumaskcc`s-tj|�}z	dVWdtj|�XdS(u8Context manager that temporarily sets the process umask.N(RJtumask(R�toldmask((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
temp_umask<s	cC`s�tjj|�r|S|dk	r:tjj||�}ntj}tjj|�g|}x9|D]1}tjj||�}tjj|�rc|SqcW|S(u�Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).N(RJRKtisabsR*R^R RUtexists(tfiletheretsubdirRKtdntfn((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytfindfileFs	
cC`s4tj|tjtjBtjB�}tj|�dS(u>Create an empty file. If the file already exists, truncate it.N(RJRtO_WRONLYtO_CREATtO_TRUNCR�(RZtfd((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcreate_empty_fileUs#cC`sFt|j��}g|D]}d|^q}dj|�}d|S(u%Like repr(dict), but in sorted order.u%r: %ru, u{%s}(tsortedR4R^(tdictR4tpairt	reprpairst
withcommas((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytsortdictZscC`s9ttd�}z|j�SWd|j�tt�XdS(u`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    uwbN(RtTESTFNtfilenoR�RY(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytmake_bad_fdas

cC`s|jtt|dd�dS(Nu
<test string>uexec(tassertRaisestSyntaxErrortcompile(ttestcaset	statement((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcheck_syntax_errormsc`s~ddlm}m}�jdd��|j|�djd�d}tjj	tjj
t�d|�}���fd�}tjj|�r�||�}|dk	r�|St
|�ntd	�td
|dt��|j|dd
�}zNt|d��9}	|j�}
x#|
r8|	j|
�|j�}
qWWdQXWd|j�X||�}|dk	rj|Std|��dS(Ni(trequesttparseucheckiu/i����udatac`sMt|���}�dkr"|S�|�r?|jd�|S|j�dS(Ni(RR*tseekR�(R�R-(R�tcheckR�(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcheck_valid_file{s
uurlfetchu	fetching %s ...R�RViuwbuinvalid resource %r(tfuture.backports.urllibR�R�tpopR*turlparseRLRJRKR^RUt__file__R�RYR�tprintRGturlopenRtreadtwriteR�R(turlR�R�turllib_requestturllib_parseRZR�R�R-toutts((R�R�R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytopen_urlresourceqs0 $	

	
tWarningsRecordercB`s8eZdZd�Zd�Zed��Zd�ZRS(uyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    cC`s||_d|_dS(Ni(t	_warningst_last(tselft
warnings_list((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__init__�s	cC`s\t|j�|jkr,t|jd|�S|tjjkrBdStd||f��dS(Ni����u%r has no attribute %r(	tlenR�R�R?RtWarningMessaget_WARNING_DETAILSR*R@(R�tattr((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__getattr__�s
cC`s|j|jS(N(R�R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�scC`st|j�|_dS(N(RR�R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytreset�s(R
RRRRtpropertyRR(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s
		cc`s�tjd�}|jjd�}|rgtjr=|j�qgx'tt|��D]}|j	�qPWnt
jdt��&}tj
djd�t|�VWdQXt|�}g}x�|D]�\}}	t}
x^|D]U}|j}tj|t|�tj�r�t|j|	�r�t}
|j|�q�q�W|
r�|r�|j||	jf�q�q�W|rutd|d��n|r�td	|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__trecorduwarningsualwaysNuunhandled warning %siu)filter (%r, %s) did not catch any warning(R R�R�R�RtPY3tclearRRR�RRR'R!tsimplefilterR�R
R)tmessagetretmatchRtIt
issubclasst	__class__tremoveR3R
tAssertionError(tfiltersR�tframetregistrytitwtreraisetmissingRtcattseentwarning((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_filterwarnings�s6	
	cO`sI|jd�}|s<dtff}|dkr<t}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)
    uquietuN(R�tWarningR*R'R(RtkwargsR�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcheck_warnings�stCleanImportcB`s)eZdZd�Zd�Zd�ZRS(u,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
    cG`sotjj�|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(R R!tcopytoriginal_modulesR
(R�tmodule_namestmodule_nameR<((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRs

cC`s|S(N((R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	__enter__scG`stjj|j�dS(N(R R!tupdateR%(R�t
ignore_exc((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__exit__s(R
RRRR(R+(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR#�s
	
	tEnvironmentVarGuardcB`sqeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
RS(u_Class to help protect the environment variable properly.  Can be used as
    a context manager.cC`stj|_i|_dS(N(RJtenviront_environt_changed(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR&scC`s|j|S(N(R.(R�tenvvar((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__getitem__*scC`s<||jkr+|jj|�|j|<n||j|<dS(N(R/R.R�(R�R0tvalue((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__setitem__-scC`sK||jkr+|jj|�|j|<n||jkrG|j|=ndS(N(R/R.R�(R�R0((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__delitem__3scC`s
|jj�S(N(R.tkeys(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR5:scC`s
t|j�S(N(titerR.(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__iter__=scC`s
t|j�S(N(RR.(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt__len__@scC`s|||<dS(N((R�R0R2((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytsetCscC`s||=dS(N((R�R0((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytunsetFscC`s|S(N((R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR(IscG`shxU|jj�D]D\}}|dkrG||jkrT|j|=qTq||j|<qW|jt_dS(N(R/R4R*R.RJR-(R�R*tktv((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR+Ls(R
RRRR1R3R4R5R7R8R9R:R(R+(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR,!s										t
DirsOnSysPathcB`s)eZdZd�Zd�Zd�ZRS(u�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.
    cG`s-tj|_tj|_tjj|�dS(N(R RKtoriginal_valuetoriginal_objecttextend(R�tpaths((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRbs
cC`s|S(N((R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR(gscG`s|jt_|jtj(dS(N(R?R RKR>(R�R*((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR+js(R
RRRR(R+(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR=Vs
		tTransientResourcecB`s2eZdZd�Zd�Zdddd�ZRS(u�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.cK`s||_||_dS(N(texctattrs(R�RCR!((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRts	cC`s|S(N((R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR(xscC`s}|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(R*RRCRDR4R�R?R(R�ttype_R2t	tracebackRt
attr_value((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR+{sN(R
RRRR(R*R+(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRBos		Rdg>@c#`s�dddddg}d d!d"d#d$g}td|��|�g��s�g|D]\}}tt||�^qS�g|D]\}}tt||�^q~�n���fd�}tj�}z�y%|dk	r�tj|�ndVWn�tk
r�}	xxtrz|	j	}
t
|
�dkrDt|
dt�rD|
d}	qt
|
�dkrvt|
dt�rv|
d}	qPqW||	��nXWdtj|�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_AGAINi����uEAI_FAILi����u
EAI_NONAMEi����u
EAI_NODATAi����u
WSANO_DATAi�*uResource %r is not availablec`s�t|dd�}t|tj�sNt|tj�rB|�ksN|�kr�tsrtjj	�j
dd�n�}||_|�ndS(Nuerrnoiu
(R?R*t
isinstanceR�RVR�tverboseR tstderrR�R�t	__cause__(terrtnRC(tcaptured_errnostdeniedt
gai_errnos(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytfilter_error�s	Niii(uECONNREFUSEDio(u
ECONNRESETih(uEHOSTUNREACHiq(uENETUNREACHie(u	ETIMEDOUTin(u	EAI_AGAINi����(uEAI_FAILi����(u
EAI_NONAMEi����(u
EAI_NODATAi����(u
WSANO_DATAi�*(RR?RdR�tgetdefaulttimeoutR*tsetdefaulttimeouttIOErrorR'R�RRH(t
resource_nameRVterrnostdefault_errnostdefault_gai_errnosRtnumRQtold_timeoutRLta((RNRORPsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyttransient_internet�sH		(+
			%
%

cc`s[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(tioR?R tsetattrtStringIO(tstream_nameR]torig_stdout((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_output�scC`s
td�S(u�Capture the output of sys.stdout:

       with captured_stdout() as s:
           print("hello")
       self.assertEqual(s.getvalue(), "hello")
    ustdout(Rb(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_stdout�scC`s
td�S(Nustderr(Rb(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_stderr�scC`s
td�S(Nustdin(Rb(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_stdin�scC`s8tj�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(tgctcollectt	is_jythonRNRO(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
gc_collect�s



cc`s:tj�}tj�z	dVWd|r5tj�nXdS(N(Rft	isenabledtdisabletenable(thave_gc((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
disable_gcs
	cC`slddl}|jd�pd}d}x,|j�D]}|jd�r4|}q4q4W|dkok|dkS(u,Find if Python was built with optimizations.iNu	PY_CFLAGSuu-Ou-O0(Rtget_config_varRLR#(Rtcflagst	final_opttopt((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytpython_is_optimizeds
unPu0nugettotalrefcountu2Pu0PuncC`stjt|t�S(N(tstructtcalcsizet_headert_align(tfmt((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcalcobjsizescC`stjt|t�S(N(RtRut_vheaderRw(Rx((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcalcvobjsize"sii	cC`s�tj|�}t|�tkr.|jt@sSt|�tkrct|�jt@rc|tj7}ndt|�||f}|j|||�dS(Nu&wrong size for %s: got %d, expected %d(	R t	getsizeofR�t	__flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCt	_testcapitSIZEOF_PYGC_HEADtassertEqual(ttesttotsizetresultR((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcheck_sizeof)s%c`s��fd�}|S(Nc`s1���fd�}�j|_�j|_|S(Nc`s�y.ddl}t|��}|j|�}Wn$tk
rD�nAd}}n1Xx-�D]%}y|j||�PWq\q\Xq\Wz�||�SWd|r�|r�|j||�nXdS(Ni(tlocaleR?t	setlocaleR@R*(R�tkwdsR�tcategorytorig_localetloc(tcatstrRRtlocales(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytinner9s$

(R
R(RRR�(R�R�(RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�8s((R�R�R�((R�R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrun_with_locale7sc`s�fd�}|S(Nc`s.��fd�}�j|_�j|_|S(Nc`s�y
tj}Wn tk
r/tjd��nXdtjkrOtjd}nd}�tjd<|�z�||�SWd|dkr�tjd=n
|tjd<tj�XdS(Nutzset requireduTZ(RNttzsetR@RRRJR-R*(R�R�R�torig_tz(RRttz(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�]s




(R
R(RRR�(R�(RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�\s((R�R�((R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrun_with_tz[sicC`s�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(t_1Mt_1GRRt
IGNORECASEtVERBOSER*R�Rtfloattgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2Gt
max_memuse(tlimittsizestmtmemlimit((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytset_memlimit�s 2	t_MemoryWatchdogcB`s)eZdZd�Zd�Zd�ZRS(u`An object which periodically watches the process' memory consumption
    and prints it out.
    cC`s(djdtj��|_t|_dS(Nu/proc/{pid}/statmtpid(tformatRJtgetpidtprocfileR)tstarted(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�scC`s�yt|jd�}Wn:tk
rR}tjdj|�t�tjj	�dSXt
d�}tjtj
|gd|dtj�|_|j�t|_dS(Nuru"/proc not available for stats: {0}umemory_watchdog.pytstdinRJ(RR�RcRRPR�RQR RJtflushR�t
subprocesstPopent
executabletDEVNULLtmem_watchdogR�R'R�(R�R-tetwatchdog_script((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytstart�s

cC`s*|jr&|jj�|jj�ndS(N(R�R�t	terminatetwait(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytstop�s	
(R
RRRR�R�(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s		c`s���fd�}|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.
    c`s+���fd����_��_�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}Gtpeaki@i@(R�tmemuseR�RRRIR�R�R�R�R*R�(R�R�R�tmaxsizetwatchdog(tdry_runR-R�(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s*			
	
(R�R�(R-(R�R�R�(R-R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s		((R�R�R�R�((R�R�R�sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
bigmemtest�s
!c`s�fd�}|S(u0Decorator for tests that fill the address space.c`s^ttkrPtd
kr6tdkr6tjd��qZtjdtd��n
�|�SdS(
Nii?iiu-not enough memory: try a 32-bit build insteadu'not enough memory: %.1fG minimum needediill����I�i@(R�R�RR(R�(R-(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s((R-R�((R-sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytbigaddrspacetest�stBasicTestRunnercB`seZd�ZRS(cC`stj�}||�|S(N(Rt
TestResult(R�R�R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrun�s
(R
RR�(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��scC`s|S(N((RA((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt_id�scC`sM|dkr#t�r#tjd�St|�r3tStjdj|��SdS(Nuguiuresource 'gui' is not availableuresource {0!r} is not enabled(R�RtskipR�R�R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrequires_resources

cC`stdt�|�S(u9
    Decorator for tests only applicable on CPython.
    tcpython(timpl_detailR'(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcpython_onlyscK`s}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 (
tcheck_impl_detailR�R*t
_parse_guardsR�R5R�R^RR�(Rtguardst
guardnamestdefault((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�s	cC`s8|sitd6tfSt|j��d}||fS(Nucpythoni(R'R)R
tvalues(R�tis_true((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�scK`s.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
    (R�R�R�tpython_implementationR�(R�R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�%sc`s9ttd�s�Stj���fd��}|SdS(uEDecorator to temporarily turn off tracing for the duration of a test.ugettracec`s?tj�}ztjd��||�SWdtj|�XdS(N(R tgettracetsettraceR*(R�R!toriginal_trace(RR(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�5s

N(R�R R�R�(RRR�((RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
no_tracing0scC`stt|��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.

    (R�R�(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
refcount_test@scC`srg}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(t_testsRHRt	TestSuitet
_filter_suiteR3(tsuitetpredtnewtestsR�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�Ks
cC`s�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.t	verbosityitfailfastiiumultiple errors occurredu!; run in verbose mode for detailsN(
RIRtTextTestRunnerR RER�R�R�t
wasSuccessfulRterrorstfailuresR(R�trunnerR�RL((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
_run_suiteWs	
cG`s�tjtjf}tj�}x�|D]�}t|t�rx|tjkri|jtjtj|��q�t	d��q%t||�r�|j|�q%|jtj
|��q%Wd�}t||�t|�dS(u1Run tests from unittest.TestCase-derived classes.u)str arguments must be keys in sys.modulescS`sJtdkrtSx3|j�jd�D]}tj|t�r&tSq&WtS(Nu.(tmatch_testsR*R'tidRLtfnmatchtfnmatchcaseR)(R�R((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	case_predysN(
RR�tTestCaseRHRR R!taddTestt
findTestCasesR�t	makeSuiteR�R�(tclassestvalid_typesR�tclsR�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrun_unittestks
 	
cC`s�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).
    iNRItoptionflagsu%d of %d doctests failedu,doctest (%s) ... %d tests with zero failures(tdoctestR*RIttestmodRR�R
(R<R�R�R�R-tt((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytrun_doctest�s	!cC`stjj�fS(N(R R!R$(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
modules_setup�scC`s�gtjj�D]'\}}|jd�r||f^q}x*tttj��D]}tjj�qSWtjj|�tjj|�dS(Nu
encodings.(R R!R4R#RRR�R)(t
oldmodulesR;R<t	encodingsR((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytmodules_cleanup�s!cC`strtj�fSdSdS(Ni(i(t_threadt_count(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytthreading_setup�s
cC`sTts
dSd}x=t|�D]/}tj�}||kr?Pntjd�qWdS(Ni
g�������?(R�RR�RNRO(t
nb_threadst
_MAX_COUNTtcountRM((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytthreading_cleanup�sc`s,ts
�Stj���fd��}|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.
    c`s)t�}z�|�SWdt|�XdS(N(R�R(R�tkey(RR(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR��s	(R�R�R�(RRR�((RRsN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytreap_threads�scC`scttd�r_d}xGtr[y/tj|tj�\}}|dkrLPnWqPqXqWndS(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.
    uwaitpidi����iN(R�RJR'twaitpidtWNOHANG(tany_processR�tstatus((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt
reap_children�s		cc`s|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(R�R?R^tdelattr(RARtnew_valtreal_val((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	swap_attr
s
		cc`s\||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((RAtitemR	R
((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	swap_item%s


	
	cC`stjdd|�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?R/(Rtsubtstrip(RJ((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytstrip_python_stderr@scC`s
tj�S(unReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.(R�t_args_from_interpreter_flags(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytargs_from_interpreter_flagsJstTestHandlercB`s,eZd�Zd�Zd�Zd�ZRS(cC`s#tjjj|d�||_dS(Ni(tloggingthandlerstBufferingHandlerRtmatcher(R�R((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRTscC`stS(N(R)(R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytshouldFlush]scC`s$|j|�|jj|j�dS(N(R�tbufferR3t__dict__(R�R	((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytemit`s
cK`s=t}x0|jD]%}|jj||�rt}PqqW|S(uW
        Look for a saved dict whose keys/values match the supplied arguments.
        (R)RRtmatchesR'(R�R!R�td((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRds(R
RRRRR(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRSs				tMatchercB`s eZdZd�Zd�ZRS(umsgumessagecK`sSt}xF|D]>}||}|j|�}|j|||�s
t}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.
        (R'R�tmatch_valueR)(R�RR!R�R;R<tdv((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRss

cC`sjt|�t|�kr!t}nEt|�tk	sB||jkrQ||k}n|j|�dk}|S(uT
        Try to match a single stored value (dv) with a supplied value (v).
        i(R�R)Rt_partial_matchestfind(R�R;R R<R�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR�s	!(umsgumessage(R
RR!RR(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyRos	cC`sntdk	rtStd}ytjt|�t}Wn tttfk
rVt	}nXtj
|�|a|S(Nucan_symlink(t_can_symlinkR*R�RJtsymlinkR'RctNotImplementedErrorR@R)R(tsymlink_pathtcan((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcan_symlink�s



cC`s,t�}d}|r|Stj|�|�S(u8Skip decorator for tests that require functional symlinku*Requires functional symlink implementation(R(RR�(R�tokR((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytskip_unless_symlink�s	c	C`stdk	rtSttd�s(t}n�tj�\}}z�ttd���}yutj	|dd�tj	|j
�dd�tj�}t
jd|�}|dkp�t|jd��dk}Wntk
r�t}nXWdQXWdtt�t|�X|a|S(Nusetxattruwbs	user.testR/u
2.6.(\d{1,2})ii'(t
_can_xattrR*R�RJR)ttempfiletmkstempRR�tsetxattrR�R�R�RRRR�RcRY(R'ttmp_fpttmp_nametfptkernel_versionR�((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt	can_xattr�s&	+

cC`s,t�}d}|r|Stj|�|�S(uDSkip decorator for tests that require functional extended attributesu(no non-broken extended attribute support(R3RR�(R�R)R((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytskip_unless_xattr�s	cc`s\ddl}|jj}d}|j|�}|j||B�z	dVWd|j|�XdS(u;Disable Windows Error Reporting dialogs using SetErrorMode.iNi(RvR|tkernel32tSetErrorMode(Rvtk32tSEM_NOGPFAULTERRORBOXtold_error_mode((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytsuppress_crash_popup�s	cc`s	dVdS(N((((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyR:�sc`s�t���t�y�j��Wn)ttfk
rOt��d��nXt�����fd�}|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'.

    c`s*�rt����n
t���dS(N(R^R((t
attr_is_localt	attr_nametobject_to_patcht	old_value(sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytcleanup�sN(	R?R)RR@R(R*R't
addCleanupR^(t
test_instanceR=R<t	new_valueR?((R;R<R=R>sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pytpatch�s


((ii@i@i@ii(i@ii(�Rt
__future__RRRRtfutureRtfuture.builtinsRRRRR	R
t
contextlibRdR�RfR�R RJR�tshutilRRR�t	unittest2RRR�RiRNRRt	distutilsR�tlogging.handlersRRtR,R
R�t	threadingtthreadR*tmultiprocessing.processtmultiprocessingtzlibtgziptbz2tlzmat__all__t	ExceptionRRRRtcontextmanagerR'RR)RR&R,R2R>RCRIR�R�R�R�R�RDRFRGRHR#RXR[R]RbRYR\RhRrRtRvtctypes.wintypesR�R�R�R�R�R�R�tHOSTtHOSTv6R�R�R�R�R�tIPV6_ENABLEDt
PIPE_MAX_SIZEt
SOCK_MAX_SIZEt
skipUnlesst
requires_zlibtrequires_bz2t
requires_lzmaRhRR�R�R�R�tSAVEDCWDR�R�R�R�R�R�R�R�R�tobjectR�RR"R#tcollections.abctcollectionstabctMutableMappingtmybasetUserDictt	DictMixinR,R=RBRTt	ETIMEDOUTttime_outRgt
ECONNRESETtsocket_peer_resettioerror_peer_resetR\RbRcRdReRiRnRsRvRwRzRyR{RR~R�R�R�R�R�R�t_4GR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR
RRRRRRR#R(R*R+R3R4R:RC(((sN/opt/alt/python27/lib/python2.7/site-packages/future/backports/test/support.pyt<module>s�".
	











						
			4					!																		>%			}'
					-, 		5D						
	
				$	#


		-				
	
						'		#					
		"				

Zerion Mini Shell 1.0