Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/test/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/test/__pycache__/support.cpython-311.pyc

�

�܋f���
�dZddlmZmZmZmZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZeed��sddlZddlZddlZddlZddlZddl Z 	ddl!Z!n#e"$r	ddl#m!Z!YnwxYwddl$Z$ddl%Z&ddl'Z'ddl(Z(	ej)r	ddl*Z*ddl+Z+nddl,Z*ddl+Z+n#e"$rdZ*dZ+YnwxYw	ddl-Z.n
#e"$rdZ.YnwxYw	ddl/Z/n
#e"$rdZ/YnwxYw	ddl0Z0n
#e"$rdZ0YnwxYw	ddl1Z1n
#e"$rdZ1YnwxYw	ddl2Z2n
#e"$rdZ2YnwxYwgd�Z3Gd	�d
e4��Z5Gd�de5��Z6Gd
�dej7��Z8ej9d�d���Z:d�d�Z;d�Z<d�Z=d�Z>d�d�Z?d�Z@dZAdZBdaCdaDdZEdZFdaGd�ZHd�ZId�ZJej�Kd��rd�d�ZLd�ZMd �ZNd!�ZOnejPZMejQZNejRZOd"�ZPd#�ZQd$�ZRd%�ZSd&�ZTej�Kd��rddlUZUddlVZUd'�ZWnd(�ZWd)�ZXd�d*�ZYd+�ZZd,�Z[d-�Z\d.�Z]d/Z^d0Z_ej`ejafd1�Zbe^fd2�Zcd3�Zded��Zed4Zfd5Zgejhe/d6��Ziejhe1d7��Zjejhe2d8��Zkej�Kd9��Zlejmd9krd:Znnd;Znd<�oenejp����Znejq��Zrej9d�d>���Zseed?��rej9d@���ZteudfdA�ZvdB�ZwdC�ZxdD�ZydE�ZzdF�Z{GdG�dHe|��Z}d�dI�Z~ej9dJ���ZGdK�dLe|��Z�ej)rddl�Z�e�j�j�Z�nddl�Z�e�j�Z�GdM�dNe���Z�GdO�dPe|��Z�GdQ�dRe|��Z�e�e�ej��S��Z�e�ej�ej��S��Z�e�e�ej��S��Z�ej9d�dU���Z�ej9dV���Z�dW�Z�dX�Z�dY�Z�dZ�Z�ej9d[���Z�d\�Z�d]Z�d^Z�eed_��rd`e�zZ�daZ�e�dbzZ�dc�Z�dd�Z�deZ�dfZ�dg�Z�dh�Z�di�Z�djZ�dke�zZ�dle�zZ�dme�zZ�ej�Z�dn�Z�Gdo�dpe|��Z�d�dq�Z�dr�Z�Gds�dte|��Z�du�Z�dv�Z�dw�Z�d�dx�Z�dy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�ej9d����Z�ej9d����Z�d��Z�d��Z�Gd��d�e&j�j���Z�Gd��d�e|��Z�da�d��Z�d��Z�da�d��Z�d��Z�ej�Kd��rej9d����Z�nej9d����Z�d��Z�dS)�zwSupporting definitions for the Python regression tests.

Backported for python-future from Python 3.3 test/support.py.
�)�absolute_import�division�print_function�unicode_literals)�utils)�str�range�open�int�map�listN�skip)�	sysconfig)J�Error�
TestFailed�ResourceDenied�
import_module�verbose�
use_resources�
max_memuse�record_original_stdout�get_original_stdout�unload�unlink�rmtree�forget�is_resource_enabled�requires�requires_freebsd_version�requires_linux_version�requires_mac_ver�find_unused_port�	bind_port�IPV6_ENABLED�	is_jython�TESTFN�HOST�SAVEDCWD�temp_cwd�findfile�create_empty_file�sortdict�check_syntax_error�open_urlresource�check_warnings�CleanImport�EnvironmentVarGuard�TransientResource�captured_stdout�captured_stdin�captured_stderr�time_out�socket_peer_reset�ioerror_peer_reset�run_with_locale�
temp_umask�transient_internet�set_memlimit�
bigmemtest�bigaddrspacetest�BasicTestRunner�run_unittest�run_doctest�threading_setup�threading_cleanup�
reap_children�cpython_only�check_impl_detail�
get_attribute�	swap_item�	swap_attr�requires_IEEE_754�TestHandler�Matcher�can_symlink�skip_unless_symlink�skip_unless_xattr�import_fresh_module�
requires_zlib�
PIPE_MAX_SIZE�failfast�anticipate_failure�run_with_tz�
requires_gzip�requires_bz2�
requires_lzma�suppress_crash_popupc��eZdZdZdS)rz*Base class for regression test exceptions.N��__name__�
__module__�__qualname__�__doc__���n/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/backports/test/support.pyrrbs������4�4�4�4rarc��eZdZdZdS)rzTest failed.Nr[r`rarbrres���������rarc��eZdZdZdS)rz�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.
    Nr[r`rarbrrhs���������rarTc#�K�|rMtj��5tjddt��dV�ddd��dS#1swxYwYdSdV�dS)z�Context manager to suppress package and module deprecation
    warnings when importing them.

    If ignore is False, this context manager has no effect.�ignorez.+ (module|package)N)�warnings�catch_warnings�filterwarnings�DeprecationWarning)rfs rb�_ignore_deprecated_importsrkps�������
�
$�
&�
&�	�	��#�H�.C�$6�
8�
8�
8��E�E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�
	�����s� A�A	�A	Fc���t|��5	tj|��cddd��S#t$r&}t	jt
|�����d}~wwxYw#1swxYwYdS)z�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)rk�	importlibr�ImportError�unittest�SkipTestr)�name�
deprecated�msgs   rbrrs���
$�J�	/�	/�.�.�	.��*�4�0�0�.�.�.�.�.�.�.�.���	.�	.�	.��#�C��H�H�-�-�-�����	.����.�.�.�.����.�.�.�.�.�.s+�A%�2�
A"�!A�A"�"A%�%A)�,A)c��|tjvrt|��tj|=ttj��D]B}||ks|�|dz��r"tj|||<tj|=�CdS)zyHelper function to save and remove a module from sys.modules

    Raise ImportError if the module can't be imported.
    �.N)�sys�modules�
__import__r
�
startswith)rq�orig_modules�modnames   rb�_save_and_remove_moduler|�s����3�;����4�����K������$�$�%�%���d�?�?�g�0�0����<�<�?�$'�K��$8�L��!���G�$��%�%rac�z�d}	tj|||<n#t$rd}YnwxYwdtj|<|S)z�Helper function to save and block a module in sys.modules

    Return True if the module was in sys.modules, False otherwise.
    TFN�rvrw�KeyError)rqrz�saveds   rb�_save_and_block_moduler��sW��

�E�� �[��.��T�����������������C�K����Ls��)�)c�$�|rtjSd�S)z�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.
    c��|S�Nr`)�fs rb�<lambda>z$anticipate_failure.<locals>.<lambda>�s��Q�ra)ro�expectedFailure)�	conditions rbrTrT�s���(��'�'��;�rar`c�F�t|��5i}g}t||��	|D]}t||���|D]'}t||��s|�|���(t	j|��}n#t$rd}YnwxYw|���D]\}	}
|
tj	|	<�|D]}tj	|=�n@#|���D]\}	}
|
tj	|	<�|D]}tj	|=�wxYw|cddd��S#1swxYwYdS)aVImport 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)
rkr|r��appendrmrrn�itemsrvrw)rq�fresh�blockedrrrz�names_to_remove�
fresh_name�blocked_name�fresh_module�	orig_name�module�name_to_removes            rbrPrP�s���:
$�J�	/�	/���������l�3�3�3�
	0�#�
B�
B�
�'�
�L�A�A�A�A� '�
9�
9��-�l�L�I�I�9�#�*�*�<�8�8�8��$�2�4�8�8�L�L���	 �	 �	 ��L�L�L�	 ����&2�%7�%7�%9�%9�
0�
0�!�	�6�)/���I�&�&�"1�
0�
0���K��/�/�
0��&2�%7�%7�%9�%9�
0�
0�!�	�6�)/���I�&�&�"1�
0�
0���K��/�/�
0�����)��������������������sG�D�AA:�9C�:B	�C�B	�	C�<D�=D�D�D�Dc�x�	t||��}|S#t$rtjd|�d|�����wxYw)z?Get an attribute, raising SkipTest if AttributeError is raised.zobject � has no attribute )�getattr�AttributeErrorrorp)�objrq�	attributes   rbrGrG�s^����C��&�&�	�����O�O�O����3�3�3��� M�N�N�N�O���s��%9�c�
�|adSr�)�_original_stdout)�stdouts rbrr�s�����rac�(�tptjSr�)r�rvr�r`rarbrrs���)�s�z�)rac�D�	tj|=dS#t$rYdSwxYwr�r~)rqs rbrrs9��
��K�������
�
�
����
���s�
�
��winc�<�||��|r|}n&tj�|��\}}|pd}d}|dkr>tj|��}|r|sn||vsdSt	j|��|dz}|dk�>t
jd|ztd���dS)Nrug����MbP?g�?�z)tests may fail, delete still pending for ���
stacklevel)	�os�path�split�listdir�time�sleeprg�warn�RuntimeWarning)�func�pathname�waitall�dirnamerq�timeout�Ls       rb�_waitforr�
s�����X�����	%��G�G��G�M�M�(�3�3�M�G�T��n��G�����m�m��
�7�#�#�A� �
�A�
�
�d�a�i�i����J�w�����q�L�G���m�m�	�
�A�H�L�$��	4�	4�	4�	4�	4�	4rac�:�ttj|��dSr�)r�r�r)�filenames rb�_unlinkr�+s�����H�%�%�%�%�%rac�:�ttj|��dSr��r�r��rmdir)r�s rb�_rmdirr�.s�����7�#�#�#�#�#rac�j���fd��t�|d���ttj|��dS)Nc�*��tj|��D]|}tj�||��}tj�|��r't�|d���tj|���htj|���}dS)NT�r�)r�r�r��join�isdirr�r�r)r�rq�fullname�
_rmtree_inners   �rbr�z_rmtree.<locals>._rmtree_inner2s�����
�4�(�(�
(�
(���7�<�<��d�3�3���7�=�=��*�*�(��]�H�d�C�C�C�C��H�X�&�&�&�&��I�h�'�'�'�'�

(�
(raTr�r�)r�r�s @rb�_rmtreer�1sK���	(�	(�	(�	(�	(�	���d�3�3�3�3����4� � � � � rac��	t|��dS#t$r+}|jtjtjfvr�Yd}~dSd}~wwxYwr�)r��OSError�errno�ENOENT�ENOTDIR)r��errors  rbrrAsg����������������;�u�|�U�]�;�;�;��<�;�;�;�;�;��������s��
A� A�Ac��	t|��dS#t$r!}|jtjkr�Yd}~dSd}~wwxYwr�)r�r�r�r�)r�r�s  rbr�r�Is[����w������������;�%�,�&�&��'�&�&�&�&�&�����������
>�9�>c��	t|��dS#t$r!}|jtjkr�Yd}~dSd}~wwxYwr�)r�r�r�r�)r�r�s  rbrrQs[�����
�
�
�
�
�������;�%�,�&�&��'�&�&�&�&�&��������r�c��tj|��}tj�tj�|����}tj�||dz��}tj||��|S)alMove a PEP 3147 pyc/pyo file to its legacy pyc/pyo location.

    The choice of .pyc or .pyo extension is done based on the __debug__ flag
    value.

    :param source: The file system path to the source file.  The source file
        does not need to exist, however the PEP 3147 pyc file must exist.
    :return: The file system path to the legacy pyc file.
    T�c)�imp�cache_from_sourcer�r�r��abspathr��rename)�source�pyc_file�up_one�
legacy_pycs    rb�make_legacy_pycr�Xsg���$�V�,�,�H�
�W�_�_�R�W�_�_�V�4�4�
5�
5�F�����f�f��&J�K�K�J��I�h�
�#�#�#��rac�\�t|��tjD]�}tj�||dz��}t|dz��t|dz��tt
j|d�����tt
j|d�������dS)z�'Forget' a module was ever imported.

    This removes the module from sys.modules and deletes any PEP 3147 or
    legacy .pyc and .pyo files.
    z.pyr��oT)�debug_overrideFN)rrvr�r�r�rr�r�)r{r�r�s   rbrrhs����7�O�O�O��8�D�D������g�w���7�7��	�v��|�����v��|�����s�$�V�D�A�A�A�B�B�B��s�$�V�E�B�B�B�C�C�C�C�D�Drac	���d}d}Gd�dtj��}tjj}|���}|stj���|��}tj���}|�||tj	|��tj
|��tj	|����}|stj���t|j|z��S)Nr�c�`�eZdZdejjfdejjfdejjfgZdS)�*_is_gui_available.<locals>.USEROBJECTFLAGS�fInherit�	fReserved�dwFlagsN)r\r]r^�ctypes�wintypes�BOOL�DWORD�_fields_r`rarb�USEROBJECTFLAGSr��s<������#�V�_�%9�:�$�f�o�&:�;�"�F�O�$9�:�<�H�H�Hrar�)
r��	Structure�windll�user32�GetProcessWindowStation�WinErrorr�r��GetUserObjectInformationW�byref�sizeof�boolr�)�	UOI_FLAGS�WSF_VISIBLEr��dll�h�uof�needed�ress        rb�_is_gui_availabler�}s����	���	<�	<�	<�	<�	<�f�.�	<�	<�	<��m�"���'�'�)�)���	$��/�#�#�#��o������&�&�(�(���+�+�A���L�����M�#����L�� � �	"�"��
�	$��/�#�#�#��C�K�+�-�.�.�.rac��dS)NTr`r`rarbr�r��s���trac�&�tduo|tvS)zPTest whether a resource is enabled.  Known resources are set by
    regrtest.py.N)r��resources rbrr�s����$�B��]�)B�Brac��|dkr"t��stjd���tjd��j�d��dkrdSt|��s|�d|z}t|���dS)z�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.
    �guizCannot use the 'gui' resourcer�r\�__main__Nz"Use of the %r resource not enabled)	r�rorprv�	_getframe�	f_globals�getrr)r�rss  rbrr�s����5���!2�!4�!4���� ?�@�@�@��}�Q���!�%�%�j�1�1�Z�?�?����x�(�(�"��;�6��A�C��S�!�!�!�"�"rac������fd�}|S)z�Decorator raising SkipTest if the OS is `sysname` and the version is less
    than `min_version`.

    For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
    the FreeBSD version is less than 7.2.
    c�Z���tj������fd���}�|_|S)Nc���tj���kr�tj���dd��d}	t	tt|�d������}|�krDd�tt�����}tj
��d|�d|�����n#t$rYnwxYw�|i|��S)N�-r�rruz	 version � or higher required, not )�platform�system�releaser��tuplerrr�rrorp�
ValueError)�args�kw�version_txt�version�min_version_txtr��min_version�sysnames     ���rb�wrapperz:_requires_unix_version.<locals>.decorator.<locals>.wrapper�s������ � �G�+�+�&�.�0�0�6�6�s�A�>�>�q�A��	G�#�C��[�->�->�s�-C�-C�$D�$D�E�E�G���,�,�*-�(�(�3�s�K�3H�3H�*I�*I��&�/�&�w�w������F�G�G�G�-��"�����D������4��$��$�$�$s�5C�
C�C��	functools�wrapsr)r�rrrs` ��rb�	decoratorz)_requires_unix_version.<locals>.decorator�sK����	���	�	�
	%�
	%�
	%�
	%�
	%�
	%�
�	�
	%�*����rar`)rrrs`` rb�_requires_unix_versionr�s*����������$�rac�"�td|��S)z�Decorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is
    less than `min_version`.

    For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD
    version is less than 7.2.
    �FreeBSD�r�rs rbrr�s��"�)�[�9�9�9rac�"�td|��S)z�Decorator raising SkipTest if the OS is Linux and the Linux version is
    less than `min_version`.

    For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux
    version is less than 2.6.32.
    �Linuxrrs rbr r �s��"�'�;�7�7�7rac����fd�}|S)z�Decorator raising SkipTest if the OS is Mac OS X and the OS X
    version if less than min_version.

    For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
    is lesser than 10.5.
    c�X���tj�����fd���}�|_|S)Nc���tjdkr�tj��d}	tt	t
|�d������}|�krBd�t	t�����}tj
d|�d|�����n#t$rYnwxYw�|i|��S)N�darwinrruz	Mac OS X r)rvr�mac_verrrrr�r�rrorpr)r
rrrrr�rs     ��rbrz4requires_mac_ver.<locals>.decorator.<locals>.wrapper�s�����|�x�'�'�&�.�0�0��3��	>�#�C��[�->�->�s�-C�-C�$D�$D�E�E�G���,�,�*-�(�(�3�s�K�3H�3H�*I�*I��&�/�/�.�����=�>�>�>�-��"�����D������4��$��$�$�$s�5B*�*
B7�6B7r)r�rrs` �rbrz#requires_mac_ver.<locals>.decorator�sF����	���	�	�
	%�
	%�
	%�
	%�
	%�
�	�
	%�*����rar`)rrs` rbr!r!�s$��������$�raz	127.0.0.1�::1c�x�tj||��}t|��}|���~|S)a�
Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as
    the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
    the specified host address (defaults to 0.0.0.0) with the port set to 0,
    eliciting an unused ephemeral port from the OS.  The temporary socket is
    then closed and deleted, and the ephemeral port is returned.

    Either this method or bind_port() should be used for any tests where a
    server socket needs to be bound to a particular port for the duration of
    the test.  Which one to use depends on whether the calling code is creating
    a python socket, or if an unused port needs to be provided in a constructor
    or passed to an external program (i.e. the -accept argument to openssl's
    s_server mode).  Always prefer bind_port() over find_unused_port() where
    possible.  Hard coded ports should *NEVER* be used.  As soon as a server
    socket is bound to a hard coded port, the ability to run multiple instances
    of the test simultaneously on the same host is compromised, which makes the
    test a ticking time bomb in a buildbot environment. On Unix buildbots, this
    may simply manifest as a failed test, which can be recovered from without
    intervention in most cases, but on Windows, the entire python process can
    completely and utterly wedge, requiring someone to log in to the buildbot
    and manually kill the affected process.

    (This is easy to reproduce on Windows, unfortunately, and can be traced to
    the SO_REUSEADDR socket option having different semantics on Windows versus
    Unix/Linux.  On Unix, you can't have two AF_INET SOCK_STREAM sockets bind,
    listen and then accept connections on identical host/ports.  An EADDRINUSE
    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.
    )�socketr#�close)�family�socktype�tempsock�ports    rbr"r"�s;��p�}�V�X�.�.�H��X���D��N�N������Krac��|jtjk�r|jtjkr�ttd��r=|�tjtj��dkrtd���ttd��rT	|�tjtj
��dkrtd���n#tj$rYnwxYwttd��r+|�tjtj
d��|�|df��|���d}|S)a%Bind the socket to a free port and return the port number.  Relies on
    ephemeral ports in order to ensure we are using an unbound port.  This is
    important as many tests may be running simultaneously, especially in a
    buildbot environment.  This method raises an exception if the sock.family
    is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR
    or SO_REUSEPORT set on it.  Tests should *never* set these socket options
    for TCP/IP sockets.  The only case for setting these options is testing
    multicasting via multiple UDP sockets.

    Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e.
    on Windows), it will be set on the socket.  This will prevent anyone else
    from bind()'ing to our host/port for the duration of the test.
    �SO_REUSEADDRr�zHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!�SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!�SO_EXCLUSIVEADDRUSEr)r)r'�AF_INET�type�SOCK_STREAM�hasattr�
getsockopt�
SOL_SOCKETr.rr/r��
setsockoptr0�bind�getsockname)�sock�hostr,s   rbr#r#9sO���{�f�n�$�$���f�6H�)H�)H��6�>�*�*�	E����v�0�&�2E�F�F�!�K�K� �"D�E�E�E��6�>�*�*�		�
��?�?�6�#4�f�6I�J�J�a�O�O�$�&H�I�I�I�P���<�
�
�
���	
����
�6�0�1�1�	N��O�O�F�-�v�/I�1�M�M�M��I�I�t�Q�i���������a� �D��Ks�=C�C$�#C$c��tjr�d}	tjtjtj��}|�d��	|r|���dSdS#tjtjf$rYnwxYw	|r|���n#|r|���wwxYwdS)z+Check whether IPv6 is enabled on this host.N)r%rTF)r'�has_ipv6�AF_INET6r3r8r(r��gaierror)r:s rb�_is_ipv6_enabledr@^s���
��
���	��=���&�2D�E�E�D��I�I�j�!�!�!���
��
�
������
�
����f�o�.�	�	�	��D�	������
��
�
�������
��
�
�����
�����5s#�>A)�)B�B"�B�B"�"B;i@iz
requires zlibzrequires bz2z
requires lzma�javaz$testz@testz{0}_{1}_tmp�tempcwdc#�0K�tj��}d}|�L|}	tj|��d}n2#t$r%|s�t	jd|ztd���YnwxYw	tj|��n2#t$r%|s�t	jd|ztd���YnwxYw	tj��V�tj|��|rt|��dSdS#tj|��|rt|��wwxYw)a�
    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.
    FNTz*tests may fail, unable to create temp CWD �r�z,tests may fail, unable to change the CWD to )	r��getcwd�mkdirr�rgr�r��chdirr)rq�quietr��	saved_dir�is_temporarys     rbr)r)ss�����	���I��L��|���	8��H�T�N�N�N��L�L���	8�	8�	8��
���M�F��M�(�Q�
8�
8�
8�
8�
8�
8�	8����
4�
���������4�4�4��	���
�D�t�K�$��	4�	4�	4�	4�	4�	4�4����
��i�k�k����
�������	��4�L�L�L�L�L�	�	��	�������	��4�L�L�L�L�	���s-�4�,A#�"A#�'A<�<,B+�*B+�/C-�-(D�umaskc#�K�tj|��}	dV�tj|��dS#tj|��wxYw)z8Context manager that temporarily sets the process umask.N)r�rK)rK�oldmasks  rbr:r:<sO�����(�5�/�/��	��E�E�E��H�W�������B�H�W�������s	�2�Ac�z�tj�|��r|S|� tj�||��}tj}tj�|��g|z}|D]E}tj�||��}tj�|��r|cS�F|S)z�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).)r�r��isabsr�rvr��exists)�file�here�subdirr��dn�fns      rbr*r*Fs���
�w�}�}�T������
���w�|�|�F�D�)�)���8�D��G�O�O�D�!�!�"�T�)�D��)�)��
�W�\�\�"�d�
#�
#��
�7�>�>�"���(�b�y�y�y�(��Krac��tj|tjtjztjz��}tj|��dS)z>Create an empty file. If the file already exists, truncate it.N)r�r
�O_WRONLY�O_CREAT�O_TRUNCr()r��fds  rbr+r+Us4��	���2�;���3�b�j�@�	A�	A�B��H�R�L�L�L�L�Lrac��t|�����}d�|D��}d�|��}d|zS)z%Like repr(dict), but in sorted order.c��g|]}d|z��S)z%r: %rr`)�.0�pairs  rb�
<listcomp>zsortdict.<locals>.<listcomp>]s��3�3�3�T��D��3�3�3raz, z{%s})�sortedr�r�)�dictr��	reprpairs�
withcommass    rbr,r,ZsF���4�:�:�<�<� � �E�3�3�U�3�3�3�I����9�%�%�J��J��rac��ttd��}	|���|���t	t��S#|���t	t��wxYw)z`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    �wb)r
r&�filenor(r�rQs rb�make_bad_fdrhas]��
�����D���{�{�}�}��
�
�����v������	
�
�
�����v�������s�A�*A=c�L�|�tt|dd��dS)Nz
<test string>�exec)�assertRaises�SyntaxError�compile)�testcase�	statements  rbr-r-ms/�����+�w�	�)�6�3�3�3�3�3rac�����ddlm}m}��dd���|�|��d�d��d}tj�tj�	t��d|��}���fd�}tj�|��r||��}|�|St|��td	��td
|zt�����|�|d�
��}	t#|d��5}	|���}
|
r+|	�|
��|���}
|
�+ddd��n#1swxYwY|���n#|���wxYw||��}|�|St+d|z���)Nr)�request�parse�checkr��/����datac���t|g��Ri���}��|S�|��r|�d��|S|���dS�Nr)r
�seekr()rUr�r
rsrs  ���rb�check_valid_filez*open_urlresource.<locals>.check_valid_file{s_�����!�d�!�!�!�b�!�!���=��H�
�U�1�X�X�	�
�F�F�1�I�I�I��H�	���	�	�	�	�	ra�urlfetchz	fetching %s ...rg�)r�rezinvalid resource %r)�future.backports.urllibrqrr�pop�urlparser�r�r�r�r��__file__rPrr�printr�urlopenr
�read�writer(r)�urlr
r�urllib_request�urllib_parser�rUrzr��out�srss ``        @rbr.r.qs3�����@�@�@�@�@�@�@�@�
�F�F�7�D�!�!�E��$�$�S�)�)�!�,�2�2�3�7�7��;�H�	����b�g�o�o�h�/�/���	B�	B�B��������
�w�~�~�b������R� � ���=��H��r�
�
�
�
�Z����	�
��
#�*=�*?�*?�@�@�@�@����s�B��/�/�A��
�"�d�^�^�	�s������A��
��	�	�!�����F�F�H�H���
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���	�	�	�	�����	�	�	�	���������A��}���
�*�R�/�
0�
0�0s1�$F"�4AF�6F"�F�F"�	F�
F"�"F8c�:�eZdZdZd�Zd�Zed���Zd�ZdS)�WarningsRecorderzyConvenience wrapper for the warnings list returned on
       entry to the warnings.catch_warnings() context manager.
    c�"�||_d|_dSrx��	_warnings�_last)�self�
warnings_lists  rb�__init__zWarningsRecorder.__init__�s��&�����
�
�
rac���t|j��|jkrt|jd|��S|tjjvrdSt|�d|�����)Nrur�)�lenr�r�r�rg�WarningMessage�_WARNING_DETAILSr�)r��attrs  rb�__getattr__zWarningsRecorder.__getattr__�s_���t�~�����+�+��4�>�"�-�t�4�4�4�
�X�,�=�
=�
=��4�����t�t�D�E�E�Erac�*�|j|jd�Sr�r��r�s rbrgzWarningsRecorder.warnings�s���~�d�j�k�k�*�*rac�8�t|j��|_dSr�)r�r�r�r�s rb�resetzWarningsRecorder.reset�s�����(�(��
�
�
raN)	r\r]r^r_r�r��propertyrgr�r`rarbr�r��si�����������F�F�F��+�+��X�+�)�)�)�)�)rar�c#�K�tjd��}|j�d��}|rTtjr|���n3tt|����D]}|�	���tjd���5}tjd�
d��t|��V�ddd��n#1swxYwYt|��}g}|D]�\}}	d}
|dd�D]b}|j}t#j|t'|��t"j��r,t+|j|	��rd}
|�|���c|
s|s|�||	jf����|rt5d	|d
z���|rt5d|d
z���dS)z�Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.
    r��__warningregistry__T)�recordrg�alwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)rvrrrr�PY3�clearr	r�r~rgrhrw�simplefilterr�r
�message�re�matchr�I�
issubclass�	__class__�remover�r\�AssertionError)�filtersrH�frame�registry�i�w�reraise�missingrs�cat�seen�warnings            rb�_filterwarningsr��s'����
�M�!���E���"�"�#8�9�9�H����9�	��N�N������3�x�=�=�)�)�
�
���������	�	 ��	-�	-�	-�"��	��J��,�,�X�6�6�6��q�!�!�!�!�!�"�"�"�"�"�"�"�"�"�"�"����"�"�"�"��1�g�g�G��G��0�0���S��������	"�	"�A��i�G����c�'�l�l�B�D�1�1�
"��7�,�c�2�2�
"������q�!�!�!���	0�E�	0��N�N�C���.�/�/�/���B��3�g�a�j�@�A�A�A��)��H�$�Q�Z�(�)�)�	)�)�)s�7C�C#�&C#c�l�|�d��}|sdtff}|�d}t||��S)a�Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)
    rH�NT)r�Warningr�)r��kwargsrHs   rbr/r/�sC��
�J�J�w���E�����=�"���=��E��7�E�*�*�*rac�$�eZdZdZd�Zd�Zd�ZdS)r0a,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
    c���tj���|_|D]L}|tjvr<tj|}|j|krtj|j=tj|=�MdSr�)rvrw�copy�original_modulesr\)r��module_names�module_namer�s    rbr�zCleanImport.__init__sp�� #�� 0� 0� 2� 2���'�		-�		-�K��c�k�)�)���[�1��
�?�k�1�1���F�O�4��K��,��		-�		-rac��|Sr�r`r�s rb�	__enter__zCleanImport.__enter__����rac�N�tj�|j��dSr�)rvrw�updater��r��
ignore_excs  rb�__exit__zCleanImport.__exit__s!������4�0�1�1�1�1�1raN�r\r]r^r_r�r�r�r`rarbr0r0�sK������	�	�-�-�-����2�2�2�2�2rar0c�T�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
S)r1z_Class to help protect the environment variable properly.  Can be used as
    a context manager.c�6�tj|_i|_dSr�)r��environ�_environ�_changedr�s rbr�zEnvironmentVarGuard.__init__&s���
��
���
�
�
rac��|j|Sr�)r��r��envvars  rb�__getitem__zEnvironmentVarGuard.__getitem__*s���}�V�$�$rac�p�||jvr"|j�|��|j|<||j|<dSr��r�r�r�r�r��values   rb�__setitem__zEnvironmentVarGuard.__setitem__-s=�����&�&�$(�M�$5�$5�f�$=�$=�D�M�&�!� %��
�f���rac��||jvr"|j�|��|j|<||jvr
|j|=dSdSr�r�r�s  rb�__delitem__zEnvironmentVarGuard.__delitem__3sP�����&�&�$(�M�$5�$5�f�$=�$=�D�M�&�!��T�]�"�"��
�f�%�%�%�#�"rac�4�|j���Sr�)r��keysr�s rbr�zEnvironmentVarGuard.keys:s���}�!�!�#�#�#rac�*�t|j��Sr�)�iterr�r�s rb�__iter__zEnvironmentVarGuard.__iter__=s���D�M�"�"�"rac�*�t|j��Sr�)r�r�r�s rb�__len__zEnvironmentVarGuard.__len__@s���4�=�!�!�!rac��|||<dSr�r`r�s   rb�setzEnvironmentVarGuard.setCs����V���rac��||=dSr�r`r�s  rb�unsetzEnvironmentVarGuard.unsetFs
����L�L�Lrac��|Sr�r`r�s rbr�zEnvironmentVarGuard.__enter__Ir�rac��|j���D]#\}}|�||jvr|j|=�||j|<�$|jt_dSr�)r�r�r�r�r�)r�r��k�vs    rbr�zEnvironmentVarGuard.__exit__Ls\���m�)�)�+�+�	%�	%�F�Q���y���
�%�%��
�a�(��#$��
�a� � ��]��
�
�
raN)r\r]r^r_r�r�r�r�r�r�r�r�r�r�r�r`rarbr1r1!s������������%�%�%�&�&�&�&�&�&�$�$�$�#�#�#�"�"�"����������#�#�#�#�#rar1c�$�eZdZdZd�Zd�Zd�ZdS)�
DirsOnSysPatha�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.
    c��tjdd�|_tj|_tj�|��dSr�)rvr��original_value�original_object�extend)r��pathss  rbr�zDirsOnSysPath.__init__bs8��!�h�q�q�q�k���"�x������������rac��|Sr�r`r�s rbr�zDirsOnSysPath.__enter__gr�rac�T�|jt_|jtjdd�<dSr�)r�rvr�r�r�s  rbr�zDirsOnSysPath.__exit__js"���'����)��������raNr�r`rarbr�r�VsK������	�	����
���*�*�*�*�*rar�c�&�eZdZdZd�Zd�Zdd�ZdS)r2z�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.c�"�||_||_dSr�)�exc�attrs)r�r�r�s   rbr�zTransientResource.__init__ts�������
�
�
rac��|Sr�r`r�s rbr�zTransientResource.__enter__xr�raNc���|�mt|j|��rZ|j���D]/\}}t	||��sdSt||��|krdS�0t
d���dSdS)z�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).Nz%an optional resource is not available)r�r�r�r�r4r�r)r��type_r��	tracebackr��
attr_values      rbr�zTransientResource.__exit__{s������D�H�e�!<�!<��$(�J�$4�$4�$6�$6�
N�
N� ��j��u�d�+�+���E�E��5�$�'�'�:�5�5��E�E�6�%�%L�M�M�M����ra)NNNr�r`rarbr2r2osX������I�I�������N�N�N�N�N�Nrar2)r��>@c#�t�	�
�K�gd�}gd�}td|z���
|�	g��	sd�|D���	d�|D����	�
�fd�}tj��}	|�tj|��dV�n�#t$r�}	|j}t
|��d	kr$t|d
t��r	|d
}n8t
|��dkr$t|d	t��r	|d	}nn�w||���d}~wwxYw	tj|��dS#tj|��wxYw)z�Return a context manager that raises ResourceDenied when various issues
    with the Internet connection manifest themselves as exceptions.))�ECONNREFUSED�o)�
ECONNRESET�h)�EHOSTUNREACH�q)�ENETUNREACH�e)�	ETIMEDOUT�n))�	EAI_AGAIN���)�EAI_FAIL���)�
EAI_NONAME���)�
EAI_NODATA���)�
WSANO_DATAi�*zResource %r is not availablec�@�g|]\}}tt||����Sr`)r�r��r]rq�nums   rbr_z&transient_internet.<locals>.<listcomp>�s8��>�>�>�*��c�#�5�$��4�4�>�>�>rac�@�g|]\}}tt||����Sr`)r�r'rs   rbr_z&transient_internet.<locals>.<listcomp>�s8��=�=�=�%�4���f�d�C�0�0�=�=�=rac� ��t|dd��}t|tj��s"t|tj��r|�vs|�vr?t
s-tj��j	ddz���}||_
|�dS)Nr�r�
)r��
isinstancer'r�r?rrv�stderrr�r
�	__cause__)�err�nr��captured_errnos�denied�
gai_errnoss   ���rb�filter_errorz(transient_internet.<locals>.filter_error�s�����C��$�'�'���s�F�N�+�+�		�
��V�_�
-�
-�		�23�z�/�/�
�� � ��
8��
� � ���Q��$�!6�7�7�7��C��C�M��I�
!� raNTr�rr�)rr'�getdefaulttimeout�setdefaulttimeout�IOErrorr
r�r)�
resource_namer��errnos�default_errnos�default_gai_errnosr�old_timeoutr�arrrs         @@@rbr;r;�s�����������N������:�]�J�
K�
K�F��O��J��=�>�>�.<�>�>�>��=�=�);�=�=�=�
���������*�,�,�K�.����$�W�-�-�-�
����������
	���A��1�v�v��{�{�z�!�A�$��8�8�{���d����Q���1����A�a�D�'�!:�!:����d����
	�	��S����
���������	�(	� ��-�-�-�-�-��� ��-�-�-�-���s+�A4�3D!�4
D�>BD�D�D!�!D7c#�K�ddl}tt|��}tt||�����	tt|��V�tt||��dS#tt||��wxYw)z�Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.rN)�ior�rv�setattr�StringIO)�stream_namer*�orig_stdouts   rb�captured_outputr/�s������I�I�I��#�{�+�+�K��C��b�k�k�m�m�,�,�,�/��c�;�'�'�'�'�'���[�+�.�.�.�.�.����[�+�.�.�.�.���s�A4�4Bc� �td��S)z�Capture the output of sys.stdout:

       with captured_stdout() as s:
           print("hello")
       self.assertEqual(s.getvalue(), "hello")
    r��r/r`rarbr3r3�s���8�$�$�$rac� �td��S)Nrr1r`rarbr5r5�s���8�$�$�$rac� �td��S)N�stdinr1r`rarbr4r4�s���7�#�#�#rac��tj��trtjd��tj��tj��dS)a�Force as many objects as possible to be collected.

    In non-CPython implementations of Python, this is needed because timely
    deallocation is not guaranteed by the garbage collector.  (Even in CPython
    this can be the case in case of reference cycles.)  This means that __del__
    methods may be called later than expected and weakrefs may remain alive for
    longer than expected.  This function tries its best to force all garbage
    objects to disappear.
    皙�����?N)�gc�collectr%r�r�r`rarb�
gc_collectr9�s>���J�L�L�L����
�3�����J�L�L�L��J�L�L�L�L�Lrac#��K�tj��}tj��	dV�|rtj��dSdS#|rtj��wwxYwr�)r7�	isenabled�disable�enable)�have_gcs rb�
disable_gcr?sh�����l�n�n�G��J�L�L�L��
�����	��I�K�K�K�K�K�	�	��7�	��I�K�K�K�K�	���s�A�Ac��ddl}|jd��pd}d}|���D]}|�d��r|}�|dko|dkS)z,Find if Python was built with optimizations.rN�	PY_CFLAGSr�z-Oz-O0)r�get_config_varr�ry)r�cflags�	final_opt�opts    rb�python_is_optimizedrFsq������
%�Y�
%�k�
2�
2�
8�b�F��I��|�|�~�~�����>�>�$���	��I����?�1�y�E�1�1ra�nP�0n�gettotalrefcount�2P�0Prc�J�tjt|ztz��Sr�)�struct�calcsize�_header�_align��fmts rb�calcobjsizerSs���?�7�S�=�6�1�2�2�2rac�J�tjt|ztz��Sr�)rMrN�_vheaderrPrQs rb�calcvobjsizerV"s���?�8�c�>�F�2�3�3�3rai@ic�Z�tj|��}t|��tkr|jtzs4t|��tkr+t|��jt
zr|tjz
}dt|��||fz}|�|||��dS)Nz&wrong size for %s: got %d, expected %d)	rv�	getsizeofr2�	__flags__�_TPFLAGS_HEAPTYPE�_TPFLAGS_HAVE_GC�	_testcapi�SIZEOF_PYGC_HEAD�assertEqual)�testr��size�resultrss     rb�check_sizeofrb)s���
�]�1�
�
�F�	
�a���D���q�{�->�>��
�q�'�'�T�/�/��Q��� 1�4D� D�/��	�*�*��
2��A�w�w���%�&�C����V�T�3�'�'�'�'�'rac������fd�}|S)Nc�H������fd�}�j|_�j|_|S)Nc�X��	ddl}t|���}|�|��}�D]!}	|�||��n#Y�xYwn#t$r�dx}}YnxYw	�|i|��|r|r|�||��SSS#|r|r|�||��wwwxYwrx)�localer��	setlocaler�)	r
�kwdsrf�category�orig_locale�loc�catstrr��localess	      ���rb�innerz1run_with_locale.<locals>.decorator.<locals>.inner9s���
��
�
�
�"�6�6�2�2��$�.�.�x�8�8��#���C���(�(��3�7�7�7������������"�
�
�
��
,�'+�+��������
<��t�T�*�T�*�*��<�k�<��$�$�X�{�;�;�;�;�<�<��6�<�k�<��$�$�X�{�;�;�;�;�<�<���s"�)A�A	�	A
�A#�'B�B)�r\r_)r�rnrlrms` ��rbrz"run_with_locale.<locals>.decorator8s@����	<�	<�	<�	<�	<�	<�	<�2�������
��rar`)rlrmrs`` rbr9r97s*����������:�rac����fd�}|S)Nc�F�����fd�}�j|_�j|_|S)Nc���	tj}n"#t$rtjd���wxYwdt
jvrt
jd}nd}�t
jd<|��	�|i|��|�t
jd=n|t
jd<tj��S#|�t
jd=n|t
jd<tj��wxYw)Nztzset required�TZ)r��tzsetr�rorpr�r�)r
rhrt�orig_tzr��tzs    ��rbrnz-run_with_tz.<locals>.decorator.<locals>.inner]s����
:��
����!�
:�
:�
:��'�(8�9�9�9�
:�����r�z�!�!��*�T�*�����!�B�J�t���E�G�G�G�
��t�T�*�T�*�*��?��
�4�(�(�'.�B�J�t�$��
������	�?��
�4�(�(�'.�B�J�t�$��
�������s��/�/B)�)4Cro)r�rnrvs` �rbrzrun_with_tz.<locals>.decorator\s;����	�	�	�	�	�	�,�������
��rar`)rvrs` rbrUrU[s$��������4�rai�r�r�c���dttdtzd�}tjd|tjtjz��}|�t
d|�����tt|�	d����||�	d���
��z��}|a|tkrt}|tdz
krt
d|�d����|adS)	Nrw)r��m�g�tz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit r�rDz
Memory limit z too low to be useful)�_1M�_1Gr�r��
IGNORECASE�VERBOSErr�float�group�lower�real_max_memuse�MAX_Py_ssize_t�_2Gr)�limit�sizesry�memlimits    rbr<r<�s����
�
�
�#�X�	
�
�E�	��.������+�	-�	-�A��y��j�e�e�=�>�>�>��5�������$�$�u�Q�W�W�Q�Z�Z�-=�-=�-?�-?�'@�@�A�A�H��O��.� � �!���#��'����j�5�5�5�J�K�K�K��J�J�Jrac�$�eZdZdZd�Zd�Zd�ZdS)�_MemoryWatchdogz`An object which periodically watches the process' memory consumption
    and prints it out.
    c�l�d�tj�����|_d|_dS)Nz/proc/{pid}/statm)�pidF)�formatr��getpid�procfile�startedr�s rbr�z_MemoryWatchdog.__init__�s+��+�2�2�r�y�{�{�2�C�C��
�����rac��	t|jd��}nc#t$rV}tjd�|��t��tj�	��Yd}~dSd}~wwxYwtd��}tjtj
|g|tj���|_|���d|_dS)N�rz"/proc not available for stats: {0}zmemory_watchdog.py)r4rT)r
r�r�rgr�r�r�rvr�flushr*�
subprocess�Popen�
executable�DEVNULL�mem_watchdogr(r�)r�r��e�watchdog_scripts    rb�startz_MemoryWatchdog.start�s���	��T�]�C�(�(�A�A���	�	�	��M�>�E�E�a�H�H�(�
*�
*�
*��J�������F�F�F�F�F�����		����#�#7�8�8��&�,�c�n�o�-N�34�Z�=O�Q�Q�Q���	���	�	�	�����s��
A8�AA3�3A8c�|�|jr4|j���|j���dSdSr�)r�r��	terminate�waitr�s rb�stopz_MemoryWatchdog.stop�sF���<�	%���'�'�)�)�)���"�"�$�$�$�$�$�	%�	%raN)r\r]r^r_r�r�r�r`rarbr�r��sK�����������
�
�
�%�%�%�%�%rar�c��������fd�}|S)aADecorator for bigmem tests.

    'minsize' is the minimum useful size for the test (in arbitrary,
    test-interpreted units.) 'memuse' is the number of 'bytes per size' for
    the test, or a good estimate of it.

    if 'dry_run' is False, it means the test doesn't support dummy runs
    when -M is not specified.
    c�6�������fd����_��_�S)Nc�����j}�j}tsd}n|}ts�s+t||zkrtjd||zdzz���trat
rZt
��t
d�||zdz�����t��}|�	��nd}	�||��|r|�
��SS#|r|�
��wwxYw)Ni�'not enough memory: %.1fG minimum needed�@z* ... expected peak memory use: {peak:.1f}G)�peak)r`�memuser�rorprr�r�r�r�r�)r�r`r��maxsize�watchdog�dry_runr�rs     ���rbrz.bigmemtest.<locals>.decorator.<locals>.wrapper�s)����<�D��^�F�"�
������ �
5��
5�#�g��&6�6�6��'�=��f�}�	�2�4�5�5�5��
 �7�
 ������B��v�4�&�=�I�#>�v�?�?�A�A�A�*�,�,����� � � � ���
$��q��w�'�'��$��M�M�O�O�O�O�$��8�$��M�M�O�O�O�O�$���s�;C�C7)r`r�)r�rr�r�r`s`@���rbrzbigmemtest.<locals>.decorator�s=�����	$�	$�	$�	$�	$�	$�	$�:�������rar`)r`r�r�rs``` rbr=r=�s1����� � � � � � � �B�rac����fd�}|S)z0Decorator for tests that fill the address space.c����ttkrItdkrtdkrtjd���tjdtdzz����|��S)Nl����lz-not enough memory: try a 32-bit build insteadr�r�)rr�rorp)r�r�s �rbrz!bigaddrspacetest.<locals>.wrapper�st�����&�&���*�*�z�U�/B�/B��'�C�E�E�E��'�=�%��3�5�6�6�6��1�T�7�7�Nrar`)r�rs` rbr>r>�s#���
�
�
�
�
��Nrac��eZdZd�ZdS)r?c�B�tj��}||��|Sr�)ro�
TestResult)r�r_ras   rb�runzBasicTestRunner.run�s"���$�&�&����V�����
raN)r\r]r^r�r`rarbr?r?�s#����������rar?c��|Sr�r`)r�s rb�_idr��s���Jrac���|dkr"t��stjd��St|��rtStjd�|����S)Nr�zresource 'gui' is not availablezresource {0!r} is not enabled)r�rorrr�r�r�s rb�requires_resourcer�s_���5���!2�!4�!4���}�>�?�?�?��8�$�$�O��
��}�<�C�C�H�M�M�N�N�Nrac�4�td���|��S)z9
    Decorator for tests only applicable on CPython.
    T)�cpython)�impl_detail�r_s rbrErEs��%�;�t�$�$�$�T�*�*�*rac��tdi|��rtS|�bt|��\}}|rd}nd}t|�����}|�d�|����}tj|��S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or r`)	rFr��
_parse_guardsr`r�r�r�ror)rs�guards�
guardnames�defaults    rbr�r�s����"�"�6�"�"���
�
�{�+�F�3�3��
�G��	:�>�C�C�9�C��J�O�O�-�-�.�.�
��j�j����Z�0�0�1�1���=����rac���|sddidfSt|�����d}t|�����|gt|��zksJ�||fS)Nr�TFr)r
�valuesr�)r��is_trues  rbr�r�so���*��D�!�5�)�)��6�=�=�?�?�#�#�A�&�G���
�
��� � �W�I��F���$;�;�;�;�;���K� � rac��t|��\}}|�tj�����|��S)a5This function returns True or False depending on the host platform.
       Examples:
          if check_impl_detail():               # only on CPython (default)
          if check_impl_detail(jython=True):    # only on Jython
          if check_impl_detail(cpython=False):  # everywhere except on CPython
    )r�rr�python_implementationr�)r�r�s  rbrFrF%s>��$�F�+�+�O�F�G��:�:�h�4�6�6�<�<�>�>��H�H�Hrac�t��ttd��s�Stj����fd���}|S)zEDecorator to temporarily turn off tracing for the duration of a test.�gettracec���tj��}	tjd���|i|��tj|��S#tj|��wxYwr�)rvr��settrace)r
r��original_tracer�s   �rbrzno_tracing.<locals>.wrapper5s^��� �\�^�^�N�
-���T�"�"�"��t�T�,�V�,�,���^�,�,�,�,����^�,�,�,�,���s�A�A)r4rvrr)r�rs` rb�
no_tracingr�0sO����3�
�#�#����	���	�	�	-�	-�	-�	-�
�	�	-��rac�:�tt|����S)aDecorator for tests which involve reference counting.

    To start, the decorator does not run the test if is not run by CPython.
    After that, any trace function is unset during the test to prevent
    unexpected refcounts caused by the trace function.

    )r�rEr�s rb�
refcount_testr�@s���l�4�(�(�)�)�)rac���g}|jD]b}t|tj��r&t	||��|�|���B||��r|�|���c||_dS)z>Recursively filter test cases in a suite based on a predicate.N)�_testsrro�	TestSuite�
_filter_suiter�)�suite�pred�newtestsr_s    rbr�r�Ks����H���&�&���d�H�.�/�/�	&��$��%�%�%��O�O�D�!�!�!�!��t�D�z�z�
&�����%�%�%���E�L�L�Lrac���tr'tjtjdt
���}nt
��}|�|��}|���s�t|j
��dkr|js|j
dd}nAt|j��dkr|j
s|jdd}nd}ts|dz
}t|���dS)z2Run tests from a unittest.TestSuite-derived class.r�)�	verbosityrSr�rzmultiple errors occurredz!; run in verbose mode for detailsN)
rro�TextTestRunnerrvr�rSr?r��
wasSuccessfulr��errors�failuresr)r��runnerrars    rb�
_run_suiter�Ws����#��(���q�2:�<�<�<���!�"�"��
�Z�Z��
�
�F����!�!���v�}����"�"�6�?�"��-��"�1�%�C�C�
���
!�
!�Q�
&�
&�v�}�
&��/�!�$�Q�'�C�C�,�C��F�C�#F�F�C���o�o���rac��tjtjf}tj��}|D]�}t|t��rU|t
jvr8|�tjt
j|�����]td���t||��r|�|����|�tj
|������d�}t||��t|��dS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulesc��t�dS|����d��D]}tj|t��rdS� dS)NTruF)�match_tests�idr��fnmatch�fnmatchcase)r_rqs  rb�	case_predzrun_unittest.<locals>.case_predysV�����4��G�G�I�I�O�O�C�(�(�	�	�D��"�4��5�5�
��t�t�
��uraN)
ror��TestCaserrrvrw�addTest�
findTestCasesr�	makeSuiter�r�)�classes�valid_typesr��clsr�s     rbr@r@ks���%�x�'8�9�K��� � �E��	3�	3���c�3���	3��c�k�!�!��
�
�h�4�S�[��5E�F�F�G�G�G�G� �!L�M�M�M�
��[�
)�
)�	3��M�M�#������M�M�(�,�S�1�1�2�2�2�2�����%��#�#�#��u�����rac���ddl}|�t}nd}|�|||���\}}|rtd||fz���trt	d|j|fz��||fS)aRun doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    rN)r�optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestr�testmodrr�r\)r�r�r�r�r�r{s      rbrArA�s����N�N�N����	�	��	��?�?�6�9�+�?�N�N�D�A�q��>��3�q�!�f�<�=�=�=��$�
�<����"�#�	$�	$�	$��a�4�Krac�@�tj���fSr�)rvrwr�r`rarb�
modules_setupr��s���;������rac�`�d�tj���D��}tt	tj����D] }tj����!tj�|��tj�|��dS)Nc�F�g|]\}}|�d���||f��S)z
encodings.)ry)r]r�r�s   rbr_z#modules_cleanup.<locals>.<listcomp>�s@��0�0�0�D�A�q��L�L��.�.�0�!�Q��0�0�0ra)rvrwr�r	r�r~r�)�
oldmodules�	encodingsr�s   rb�modules_cleanupr��s���0�0�C�K�$5�$5�$7�$7�0�0�0�I�
�3�s�{�#�#�
$�
$�������������K���y�!�!�!��K���z�"�"�"�"�"rac�<�trtj��fSdS)N)r�)�_thread�_countr`rarbrBrB�s �����~��� � ��rrac��tsdSd}t|��D]2}tj��}||krdStjd���3dS)N�
r6)r�r	r�r�r�)�
nb_threads�
_MAX_COUNT�countrs    rbrCrC�sa�������J��z�"�"�����N�����
�?�?��E�E��
�3�����	�rac�X��ts�Stj����fd���}|S)z�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    If threading is unavailable this function does nothing.
    c�Z��t��}	�|�t|�S#t|�wxYwr�)rBrC)r
�keyr�s  �rbrzreap_threads.<locals>.decorator�s<�������	$��4��;��s�#�#�#���s�#�#�#���s��*)r�rr)r�rs` rb�reap_threadsr��sH���
�����_�T���$�$�$�$���$��rac��ttd��r8d}		tj|tj��\}}|dkrdSn#YdSxYw�5dS)z�Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.
    �waitpidruTrN)r4r�r��WNOHANG)�any_processr��statuss   rbrDrD�sn���r�9���	���	�
� �j��b�j�A�A���V��!�8�8��E���
�������	�	�	s�(A�A
c#�>K�t||��rOt||��}t|||��	dV�t|||��dS#t|||��wxYwt|||��	dV�t||��dS#t||��wxYw)amTemporary swap out an attribute with a new object.

    Usage:
        with swap_attr(obj, "attr", 5):
            ...

        This will set obj.attr to 5 for the duration of the with: block,
        restoring the old value at the end of the block. If `attr` doesn't
        exist on `obj`, it will be created and then deleted at the end of the
        block.
    N)r4r�r+�delattr)r�r��new_val�real_vals    rbrIrI
s������s�D�����3��%�%����T�7�#�#�#�	)��E�E�E��C��x�(�(�(�(�(��G�C��x�(�(�(�(������T�7�#�#�#�	��E�E�E��C��������G�C��������s�A�A�4B
�
Bc#�K�||vr#||}|||<	dV�|||<dS#|||<wxYw|||<	dV�||=dS#||=wxYw)akTemporary 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.
    Nr`)r��itemrrs    rbrHrH%s������s�{�{��t�9����D�	�	!��E�E�E� �C��I�I�I���C��I� � � � ���D�	�	��E�E�E��D�	�	�	���D�	�M�M�M�Ms� �'�9�>c�V�tjdd|�����}|S)z�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?ra)r��sub�strip)rs rb�strip_python_stderrr@s)���V�*�C��
8�
8�
>�
>�
@�
@�F��Mrac�(�tj��S)znReturn a list of command-line arguments reproducing the current
    settings in sys.flags and sys.warnoptions.)r��_args_from_interpreter_flagsr`rarb�args_from_interpreter_flagsrJs���2�4�4�4rac�&�eZdZd�Zd�Zd�Zd�ZdS)rKc�^�tjj�|d��||_dSrx)�logging�handlers�BufferingHandlerr��matcher)r�rs  rbr�zTestHandler.__init__Ts+��	��)�2�2�4��;�;�;�����rac��dS)NFr`r�s rb�shouldFlushzTestHandler.shouldFlush]s���urac�n�|�|��|j�|j��dSr�)r��bufferr��__dict__)r�r�s  rb�emitzTestHandler.emit`s2�����F��������6�?�+�+�+�+�+rac�L�d}|jD]}|jj|fi|��rd}n�|S)zW
        Look for a saved dict whose keys/values match the supplied arguments.
        FT)rr�matches)r�r�ra�ds    rbrzTestHandler.matchesdsO������	�	�A�#�t�|�#�A�0�0��0�0�
�����
��
raN)r\r]r^r�rrrr`rarbrKrKSsP������������,�,�,�	�	�	�	�	rarKc��eZdZdZd�Zd�ZdS)rL)rsr�c��d}|D]:}||}|�|��}|�|||��sd}n�;|S)a.
        Try to match a single dict with the supplied arguments.

        Keys whose values are strings and which are in self._partial_matches
        will be checked for partial (i.e. substring) matches. You can extend
        this scheme to (for example) do regular expression matching, etc.
        TF)r�match_value)r�rr�rar�r��dvs       rbrzMatcher.matchesss`�����	�	�A��q�	�A����q���B��#�#�A�r�1�-�-�
�����
��
rac���t|��t|��krd}n?t|��tus	||jvr||k}n|�|��dk}|S)zT
        Try to match a single stored value (dv) with a supplied value (v).
        Fr)r2r�_partial_matches�find)r�r�r"r�ras     rbr!zMatcher.match_value�sc����7�7�d�2�h�h����F�F�
�"�X�X�S�
 �
 �A�T�-B�$B�$B��2�g�F�F��W�W�Q�Z�Z�1�_�F��
raN)r\r]r^r$rr!r`rarbrLrLos8������)�����"
�
�
�
�
rarLc���t�tStdz}	tjt|��d}tj|��n#t
ttf$rd}YnwxYw|a|S)NrMTF)�_can_symlinkr&r��symlinkr�r��NotImplementedErrorr�)�symlink_path�cans  rbrMrM�s��������M�)�L� �
�
�6�<�(�(�(���	�	�,������
�(�.�9�������������L��Js�A�A'�&A'c�d�t��}d}|r|ntj|��|��S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)rMror�r_�okrss   rbrNrN�s4��	���B�
6�C��3�4�4�-�8�=��-�-�d�3�3�3rac��t�tSttd��sd}�n4tj��\}}	ttd��5}	tj|dd��tj|���dd��tj
��}tjd|��}|dup%t|�d����dk}n#t$rd}YnwxYwddd��n#1swxYwYt!t��t!|��n(#t!t��t!|��wxYw|a|S)	N�setxattrFres	user.testraz
2.6.(\d{1,2})r��')�
_can_xattrr4r��tempfile�mkstempr
r&r0rfrr
r�r�rr�r�r)r+�tmp_fp�tmp_name�fp�kernel_versionrys      rb�	can_xattrr9�s��������2�z�"�"�����#�+�-�-����	��f�d�#�#�
 �r�
 ��K���c�:�:�:��K��	�	���\�3�?�?�?�%-�%5�%7�%7�N����.�A�A�A��t�)�<�s�1�7�7�1�:�:���"�'<�C�C��� � � ��C�C�C� ����
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �
�6�N�N�N��8������
�6�N�N�N��8���������J��JsT�D4�D�BC'�&D�'C6�3D�5C6�6D�9D4�D	�	D4�D	�
D4�4%Ec�d�t��}d}|r|ntj|��|��S)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)r9rorr-s   rbrOrO�s4��	���B�
4�C��3�4�4�-�8�=��-�-�d�3�3�3rac#��K�ddl}|jj}d}|�|��}|�||z��	dV�|�|��dS#|�|��wxYw)z;Disable Windows Error Reporting dialogs using SetErrorMode.rNr�)r�r��kernel32�SetErrorMode)r��k32�SEM_NOGPFAULTERRORBOX�old_error_modes    rbrYrY�s�����	�
�
�
��m�$�� $���)�)�*?�@�@������*?�?�@�@�@�	-��E�E�E����^�,�,�,�,�,��C���^�,�,�,�,���s�A�A5c#�K�dV�dSr�r`r`rarbrYrY�s����
�����rac������t����d�	�j��d�n(#ttf$rt��d���YnwxYw����fd�}|�|��t��|��dS)z�Override 'object_to_patch'.'attr_name' with 'new_value'.

    Also, add a cleanup procedure to 'test_instance' to restore
    'object_to_patch' value for 'attr_name'.
    The 'attr_name' should be a valid attribute for 'object_to_patch'.

    FTNc�R���rt�����dSt����dSr�)r+r)�
attr_is_local�	attr_name�object_to_patch�	old_values����rb�cleanupzpatch.<locals>.cleanup�s9����	0��O�Y�	�:�:�:�:�:��O�Y�/�/�/�/�/ra)r�rr�r�
addCleanupr+)�
test_instancerFrE�	new_valuerHrDrGs ``  @@rb�patchrL�s��������O�Y�'�'�'��M��#�,�Y�7�	��
�
��
�H�%�>�>�>��O�Y��=�=�	�	�	�>����0�0�0�0�0�0�0�0����W�%�%�%��O�Y�	�2�2�2�2�2s�
(�"A
�A
)T)F)r`r`Fr�)rBFN)r�r`rx)�r_�
__future__rrrr�futurer�future.builtinsrr	r
rrr
�
contextlibr�rr7r'rvr�r�shutilrgror4�	unittest2rmr�r�r�r�rrn�	distutilsr��logging.handlersrrMr3r�r��	threading�thread�multiprocessing.process�multiprocessing�zlib�gzip�bz2�lzma�__all__�	Exceptionrrrpr�contextmanagerrkrr|r�rTrPrGrrrr�rSr�r�rrrryr�r�r�r�rr�rr�rr��ctypes.wintypesr�rrrrr r!r'�HOSTv6r1r3r"r#r@r$rR�
SOCK_MAX_SIZE�
skipUnlessrQrWrXr%rqr&r�r�rEr(r)r:r�r*r+r,rhr-r.�objectr�r�r/r0�collections.abc�collections�abc�MutableMapping�mybase�UserDict�	DictMixinr1r�r2r"rr6r�rr7r8r;r/r3r5r4r9r?rFrOrPrUrSrVr[rZrbr9rUr|r}r��_4Gr�r�r<r�r=r>r?r�r�rEr�r�rFr�r�r�r�r@rAr�r�rBrCr�rDrIrHrrrrrKrLr'rMrNr2r9rOrYrLr`rarb�<module>rms����
:�:�:�:�:�:�:�:�:�:�:�:�������<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�<�������������	�	�	�	�
�
�
�
�
�
�
�
�	�	�	�	�����
�
�
�
����������w�x�� � �!� � � � �����	�	�	�	�����
�
�
�
�����$��������$�$�$�#�#�#�#�#�#�#�#�$������������
�
�
�
�������y�,�!�!�!�!�!�!�!�!�!�+�+�+�+�+�+�+�+��������G��I�I�I������"�"�"�"�"�������O�O�O�������K�K�K�K�������D�D�D�������K�K�K�K�������D�D�D�������J�J�J�J������
�C�C�C�������K�K�K�K�������D�D�D���������,5�5�5�5�5�I�5�5�5���������������X�&������������
.�
.�
.�
.�%�%�%�������1�1�1�1�h������
�
�
�������
�����*�*�*�
�
�
��<���5�!�!�6�4�4�4�4�B&�&�&�$�$�$�
!�
!�
!�
!��i�G�
�X�F��m�G������������� D�D�D�$�<���5�!�!���M�M�M�����/�/�/�/�,���C�C�C�
"�"�"�"�$���6:�:�:�8�8�8����:��	��#�N�V�5G�<�<�<�<�|�#�#�#�#�J
�
�
� ��!�!��$�
�%�
�$��#�D�/�:�:�
�"�x�"�3��7�7��#��#�D�/�:�:�
��L�#�#�F�+�+�	��7�f���
�F�F�
�F�
�	�	�f�i�b�i�k�k�	2�	2��z�2�9�;�;����$�$�$���$�N�7�2�w�����������!��
�
�
�
����
���
�
�
�3�3�3�*1�*1�*1�Z)�)�)�)�)�v�)�)�)�.))�))�))�))�X��+�+���+�.2�2�2�2�2�&�2�2�2�@	�9� �����
�_�
+�F�F��O�O�O�
�
�F�2#�2#�2#�2#�2#�&�2#�2#�2#�j*�*�*�*�*�F�*�*�*�2N�N�N�N�N��N�N�N�8��W�E�O�<�<�<��%�%�f�l�%�:J�K�K�K��&�&�w�e�6F�G�G�G����A.�A.�A.���A.�H��	/�	/���	/�%�%�%�%�%�%�$�$�$���� �������	2�	2�	2���	
��
�7�3�"�#�#���W�n�G�
�F��S�=��3�3�3�4�4�4�����(�(�(����H���F��
�S�j���#�g���#�g��������*%�%�%�%�%�f�%�%�%�<+�+�+�+�Z
�
�
�$�����f�������O�O�O�+�+�+�����!�!�!�I�I�I�
�
�
� *�*�*�
�
�
����(���N����6���#�#�#�F���	�	�	����"���(�������4�������4���5�5�5������'�"�3����8�����f����D��
�
�
�4�4�4��
����64�4�4��<���5�!�!����
-�
-���
-�
-� �������3�3�3�3�3s~�6A;�;B	�B	�B6�6	C�C�C�C�C�C�C(�'C(�,C1�1C;�:C;�?D�D�
D�D�D!� D!

Hacked By AnonymousFox1.0, Coded By AnonymousFox