Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/future/backports/test/ |
| [Home] [System Details] [Kill Me] |
�
,�]cJ@`s�
dZddlmZmZmZmZddlmZddlm Z m
Z
mZmZm
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
ddd
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_portuIPV6_ENABLEDu is_jythonuTESTFNuHOSTuSAVEDCWDutemp_cwdufindfileucreate_empty_fileusortdictucheck_syntax_erroruopen_urlresourceucheck_warningsuCleanImportuEnvironmentVarGuarduTransientResourceucaptured_stdoutucaptured_stdinucaptured_stderrutime_outusocket_peer_resetuioerror_peer_reseturun_with_localeu
temp_umaskutransient_internetuset_memlimitu
bigmemtestubigaddrspacetestuBasicTestRunnerurun_unittesturun_doctestuthreading_setuputhreading_cleanupu
reap_childrenucpython_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_gzipurequires_bz2u
requires_lzmausuppress_crash_popuptErrorcB`seZdZRS(u*Base
class for regression test exceptions.(t__name__t
__module__t__doc__(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRbst
TestFailedcB`seZdZRS(uTest
failed.(R
RR(((sA/usr/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(((sA/usr/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((sA/usr/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((sA/usr/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(Rtorig_modulestmodname((sA/usr/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((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt<lambda>�s(RtexpectedFailure(t condition((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytanticipate_failure�scC`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_nametblocked_nametfresh_modulet orig_nametmoduletname_to_remove((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt
get_attribute�s
icC`s
|adS(N(t_original_stdout(tstdout((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytrecord_original_stdout�scC`s
tptjS(N(RCR
RD(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytget_original_stdoutscC`s&ytj|=Wntk
r!nXdS(N(R
R!R((R((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt_waitfor
s
cC`sttj|�dS(N(RWRItunlink(tfilename((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt_unlink+scC`sttj|�dS(N(RWRItrmdir(RT((sA/usr/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(NRS( RIRLRJtjointisdirRWR'R[RX(RJRtfullname(t
_rmtree_inner(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR`2sRS(RWR'RIR[(RJ((R`sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt_rmtree1scC`sIyt|�Wn4tk
rD}|jtjtjfkrE�qEnXdS(N(RZtOSErrorterrnotENOENTtENOTDIR(RYterror((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRXAs
cC`s@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(R\RbRcRd(RTRf((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR[Is
cC`s@yt|�Wn+tk
r;}|jtjkr<�q<nXdS(N(RaRbRcRd(RJRf((sA/usr/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_sourceRIRJRTtabspathR]t __debug__trename(tsourcetpyc_filetup_onet
legacy_pyc((sA/usr/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(
RGR
RJRIR]RXRhRiR'R)(R%RTRm((sA/usr/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_(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRt�s(
Rut Structuretwindlltuser32tGetProcessWindowStationtWinErrorRvRxtGetUserObjectInformationWtbyreftsizeoftbooltdwFlags(t UOI_FLAGStWSF_VISIBLERttdllthtuoftneededtres((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt_is_gui_available}s" cC`stS(N(R'(((sA/usr/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((sA/usr/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((sA/usr/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(tplatformtsystemtreleaseRKttupleR Rt
ValueErrorR]RRR(targstkwtversion_txttversiontmin_version_txt(RQtmin_versiontsysname(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytwrapper�s"
(t functoolstwrapsR�(RQR�(R�R�(RQsA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt decorator�s$ ((R�R�R�((R�R�sA/usr/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�((sA/usr/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�((sA/usr/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 RRKR�R]RRR(R�R�R�R�R�(RQR�(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s"
(R�R�R�(RQR�(R�(RQsA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s! ((R�R�((R�sA/usr/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((sA/usr/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�|jtjtj
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.
uSO_REUSEADDRiuHtests should never set the SO_REUSEADDR socket option
on TCP/IP sockets!uSO_REUSEPORTuHtests should never set the SO_REUSEPORT
socket option on TCP/IP
sockets!uSO_EXCLUSIVEADDRUSEi(R�R�tAF_INETttypetSOCK_STREAMthasattrt
getsockoptt
SOL_SOCKETtSO_REUSEADDRRtSO_REUSEPORTRft
setsockopttSO_EXCLUSIVEADDRUSEtbindtgetsockname(tsockthostR�((sA/usr/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'RftgaierrorR�R)(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt_is_ipv6_enabled^s
iiiu
requires
zliburequires 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 RHiu,tests may fail,
unable to change the CWD to
N(RItgetcwdR)R*tmkdirR'RbRRORPtchdirRg(RtquietRJt saved_dirtis_temporary((sA/usr/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(RItumask(R�toldmask((sA/usr/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(RIRJtisabsR*R]R
RTtexists(tfiletheretsubdirRJtdntfn((sA/usr/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(RIRtO_WRONLYtO_CREATtO_TRUNCR�(RYtfd((sA/usr/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}(tsortedR3R](tdictR3tpairt reprpairst
withcommas((sA/usr/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�RX(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytmake_bad_fdas
cC`s|jtt|dd�dS(Nu
<test
string>uexec(tassertRaisestSyntaxErrortcompile(ttestcaset statement((sA/usr/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|dd
�}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�(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcheck_valid_file{s
uurlfetchu fetching
%s ...R�RUiuwbuinvalid resource
%r(tfuture.backports.urllibR�R�tpopR*turlparseRKRIRJR]RTt__file__R�RXR�tprintRFturlopenRtreadtwriteR�R(turlR�R�turllib_requestturllib_parseRYR�R�R-toutts((R�R�R�sA/usr/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((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__getattr__�s
cC`s|j|jS(N(R�R�(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�scC`st|j�|_dS(N(RR�R�(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytreset�s(R
RRRRtpropertyRR(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s
cc`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!tsimplefilterR�R
R)tmessagetretmatchRtIt
issubclasst __class__tremoveR2R
tAssertionError(tfiltersR�tframetregistrytitwtreraisetmissingRtcattseentwarning((sA/usr/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�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcheck_warnings�stCleanImportcB`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�tmodule_namestmodule_nameR;((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRs
cC`s|S(N((R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt __enter__scG`stjj|j�dS(N(R
R!tupdateR$(R�t
ignore_exc((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__exit__s(R
RRRR'R*(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR"�s
tEnvironmentVarGuardcB`sqeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
RS(u_Class to help protect the environment variable properly.
Can be used as
a context
manager.cC`stj|_i|_dS(N(RItenviront_environt_changed(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR&scC`s|j|S(N(R-(R�tenvvar((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__getitem__*scC`s<||jkr+|jj|�|j|<n||j|<dS(N(R.R-R�(R�R/tvalue((sA/usr/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�R/((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__delitem__3scC`s
|jj�S(N(R-tkeys(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR4:scC`s
t|j�S(N(titerR-(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__iter__=scC`s
t|j�S(N(RR-(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt__len__@scC`s|||<dS(N((R�R/R1((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytsetCscC`s||=dS(N((R�R/((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytunsetFscC`s|S(N((R�((sA/usr/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.R3R*R-RIR,(R�R)tktv((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR*Ls(R
RRRR0R2R3R4R6R7R8R9R'R*(((sA/usr/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
RJtoriginal_valuetoriginal_objecttextend(R�tpaths((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRbs
cC`s|S(N((R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR'gscG`s|jt_|jtj(dS(N(R>R
RJR=(R�R)((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR*js(R
RRRR'R*(((sA/usr/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�RBR
((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRts cC`s|S(N((R�((sA/usr/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*RRBRCR3R�R>R(R�ttype_R1t tracebackRt
attr_value((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR*{sN(R
RRRR'R*R*(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRAos Rcg>@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.uECONNREFUSEDiou
ECONNRESETihuEHOSTUNREACHiquENETUNREACHieu 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�RUR�tverboseR
tstderrR�R�t __cause__(terrtnRB(tcaptured_errnostdeniedt
gai_errnos(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytfilter_error�s Niii(uECONNREFUSEDio(u
ECONNRESETih(uEHOSTUNREACHiq(uENETUNREACHie(u ETIMEDOUTin(u EAI_AGAINi����(uEAI_FAILi����(u
EAI_NONAMEi����(u
EAI_NODATAi����(u
WSANO_DATAi�*(RR>RcR�tgetdefaulttimeoutR*tsetdefaulttimeouttIOErrorR'R�RRG(t
resource_nameRUterrnostdefault_errnostdefault_gai_errnosRtnumRPtold_timeoutRKta((RMRNROsA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_output�scC`s
td�S(u�Capture the output of sys.stdout:
with captured_stdout() as s:
print("hello")
self.assertEqual(s.getvalue(), "hello")
ustdout(Ra(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_stdout�scC`s
td�S(Nustderr(Ra(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcaptured_stderr�scC`s
td�S(Nustdin(Ra(((sA/usr/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_jythonRMRN(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt
gc_collect�s
cc`s:tj�}tj�z dVWd|r5tj�nXdS(N(Ret isenabledtdisabletenable(thave_gc((sA/usr/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_varRKR#(Rtcflagst final_opttopt((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytpython_is_optimizeds
unPu0nugettotalrefcountu2Pu0PuncC`stjt|t�S(N(tstructtcalcsizet_headert_align(tfmt((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcalcobjsizescC`stjt|t�S(N(RsRtt_vheaderRv(Rw((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcalcvobjsize"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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcheck_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(tcatstrRQtlocales(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytinner9s$
(R
R(RQR�(R�R�(RQsA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�8s((R�R�R�((R�R�sA/usr/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(RMttzsetR?RRRIR,R*(R�R�R�torig_tz(RQttz(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�]s
(R
R(RQR�(R�(RQsA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�\s((R�R�((R�sA/usr/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_1GR
Rt
IGNORECASEtVERBOSER*R�Rtfloattgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2Gt
max_memuse(tlimittsizestmtmemlimit((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytset_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(tformatRItgetpidtprocfileR)tstarted(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�scC`s�yt|jd�}Wn:tk
rR}tjdj|�t�tjj �dSXt
d�}tjtj
|gd|dtj�|_|j�t|_dS(Nuru"/proc not
available for stats:
{0}umemory_watchdog.pytstdinRI(RR�RbRROR�RPR RItflushR�t
subprocesstPopent
executabletDEVNULLtmem_watchdogR�R'R�(R�R-tetwatchdog_script((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytstart�s
cC`s*|jr&|jj�|jj�ndS(N(R�R�t terminatetwait(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytstop�s
(R
RRRR�R�(((sA/usr/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�RRRHR�R�R�R�R*R�(R�R�R�tmaxsizetwatchdog(tdry_runR-R�(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s*
(R�R�(R-(R�R�R�(R-R�sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s ((R�R�R�R�((R�R�R�sA/usr/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-(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s((R-R�((R-sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytbigaddrspacetest�stBasicTestRunnercB`seZd�ZRS(cC`stj�}||�|S(N(Rt
TestResult(R�R�R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytrun�s
(R
RR�(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��scC`s|S(N((R@((sA/usr/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�((sA/usr/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�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytcpython_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�R4R�R]RR�(Rtguardst
guardnamestdefault((sA/usr/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((sA/usr/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�((sA/usr/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(RQ(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�5s
N(R�R
R�R�(RQR�((RQsA/usr/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�((sA/usr/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_testsRGRt TestSuitet
_filter_suiteR2(tsuitetpredtnewtestsR�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�Ks
cC`s�tr'tjtjdddt�}n t�}|j|�}|j�s�t |j
�dkr~|jr~|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(
RHRtTextTestRunnerR
RDR�R�R�t
wasSuccessfulRterrorstfailuresR(R�trunnerR�RK((sA/usr/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'tidRKtfnmatchtfnmatchcaseR)(R�R((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt case_predysN(
RR�tTestCaseRGRR
R!taddTestt
findTestCasesR�t makeSuiteR�R�(tclassestvalid_typesR�tclsR�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytrun_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).
iNRHtoptionflagsu%d of %d doctests failedu,doctest (%s) ... %d tests
with zero
failures(tdoctestR*RHttestmodRR�R
(R;R�R�R�R-tt((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytrun_doctest�s !cC`stjj�fS(N(R
R!R#(((sA/usr/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!R3R#RRR�R((t
oldmodulesR:R;t encodingsR((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytmodules_cleanup�s!cC`strtj�fSdSdS(Ni(i(t_threadt_count(((sA/usr/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�RMRN(t
nb_threadst
_MAX_COUNTtcountRL((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytthreading_cleanup�sc`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(RQ(sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR��s (R�R�R�(RQR�((RQsA/usr/lib/python2.7/site-packages/future/backports/test/support.pytreap_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�RIR'twaitpidtWNOHANG(tany_processR�tstatus((sA/usr/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(R@Rtnew_valtreal_val((sA/usr/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((R@titemRR ((sA/usr/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?t(R
tsubtstrip(RI((sA/usr/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(((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRTscC`stS(N(R)(R�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytshouldFlush]scC`s$|j|�|jj|j�dS(N(R�tbufferR2t__dict__(R�R((sA/usr/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((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyRds(R
RRRRR(((sA/usr/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((sA/usr/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�((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyR�s !(umsgumessage(R
RR!RR(((sA/usr/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�RItsymlinkR'RbtNotImplementedErrorR?R)R(tsymlink_pathtcan((sA/usr/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((sA/usr/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�RIR)ttempfiletmkstempRR�tsetxattrR�R�R�R
RRR�RbRX(R'ttmp_fpttmp_nametfptkernel_versionR�((sA/usr/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((sA/usr/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(RuR{tkernel32tSetErrorMode(Rutk32tSEM_NOGPFAULTERRORBOXtold_error_mode((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytsuppress_crash_popup�s cc`s dVdS(N((((sA/usr/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(sA/usr/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>sA/usr/lib/python2.7/site-packages/future/backports/test/support.pytpatch�s
((ii@i@i@ii(i@ii(�Rt
__future__RRRRtfutureRtfuture.builtinsRRRRR R
t
contextlibRcR�ReR�R
RIR�tshutilRRR�t unittest2RR
R�RhRMRRt distutilsR�tlogging.handlersRRsR,R R�t threadingtthreadR*tmultiprocessing.processtmultiprocessingtzlibtgziptbz2tlzmat__all__t ExceptionRRRRtcontextmanagerR'RR)RR&R,R1R=RBRHR�R�R�R�R�RCRERFRGR#RWRZR\RaRXR[RgRqRsRutctypes.wintypesR�R�R�R�R�R�R�tHOSTtHOSTv6R�R�R�R�R�tIPV6_ENABLEDt
PIPE_MAX_SIZEt
SOCK_MAX_SIZEt
skipUnlesst
requires_zlibtrequires_bz2t
requires_lzmaRgRR�R�R�R�tSAVEDCWDR�R�R�R�R�R�R�R�R�tobjectR�RR!R"tcollections.abctcollectionstabctMutableMappingtmybasetUserDictt DictMixinR+R<RARSt ETIMEDOUTttime_outRft
ECONNRESETtsocket_peer_resettioerror_peer_resetR[RaRbRcRdRhRmRrRuRvRyRxRzR~R}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�R�RRR
RRRRRRRR#R(R*R+R3R4R:RC(((sA/usr/lib/python2.7/site-packages/future/backports/test/support.pyt<module>s�".
4 ! >% }'
-, 5D
$ #
-
' #
"