AlkantarClanX12

Your IP : 3.21.247.78


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/future/tests/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/future/tests/__pycache__/base.cpython-311.pyc

�

�܋f�M��|�ddlmZmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZerddlZd�Zd�ZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�dej��Zejed��Zd�Z d�Z!d�Z"d�Z#e$ejd��sejj%ej_&dd�Z'e$ejd��se
ejde'��Gd�de(��Z)Gd�de)��Z*dd�Z+e$ejd��se
ejde+��dSdS)�)�print_function�absolute_importN)�dedent)�bind_method�PY26�PY3�PY2�PY27)�check_output�STDOUT�CalledProcessErrorc�^�|�d��r
|dd�}t|��S)z,
    Removes any leading 
 and dedents.
    �
�N)�
startswithr)�codes �b/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/tests/base.py�
reformat_coders1�����t�����A�B�B�x���$�<�<��c�
��|�d���d�t���D��}d�t���D��}d�t���D��}|���|ks
Jd���d�}d�}||��||��ks
Jd���t�fd	�|D����}t	t||����}t�fd
�|D����}t	t||����}	t�fd�|D����}
t	t||
����}g}t
t�����D]}}
|
|vr|�||
���"|
|vr|�|	|
���B|
|vr|�||
���b|��|
���~d�	|��S)a
    Returns the code block with any ``__future__`` import lines sorted, and
    then any ``future`` import lines sorted, then any ``builtins`` import lines
    sorted.

    This only sorts the lines within the expected blocks.

    See test_order_future_lines() for an example.
    rc�B�g|]\}}|�d���|��S)�from __future__ import �r��.0�i�lines   r�
<listcomp>z&order_future_lines.<locals>.<listcomp>*sD��N�N�N�7�1�d�"&�/�/�2K�"L�"L�N�Q�N�N�Nrc�l�g|]1\}}|�d��s|�d���/|��2S)zfrom futurez	from pastrrs   rrz&order_future_lines.<locals>.<listcomp>-sP��>�>�>���D� $���
� >� >�>� $���� <� <�>�1�>�>�>rc�B�g|]\}}|�d���|��S)z
from builtinsrrs   rrz&order_future_lines.<locals>.<listcomp>1sC��B�B�B�7�1�d� $���� @� @�B�Q�B�B�BrzIinternal usage error: dedent the code before calling order_future_lines()c�J�t|��dkrt|��ndS)Nr)�len�max��numberss r�mymaxz!order_future_lines.<locals>.mymax7s"��"�7�|�|�a�/�/�s�7�|�|�|�Q�6rc�d�t|��dkrt|��ntd��S)Nr�inf)r"�min�floatr$s r�myminz!order_future_lines.<locals>.mymin:s(��"�7�|�|�a�/�/�s�7�|�|�|�U�5�\�\�Arz2the __future__ and future imports are out of orderc� ��g|]
}�|��S�r-�rr�liness  �rrz&order_future_lines.<locals>.<listcomp>Cs���:�:�:�q�%��(�:�:�:rc� ��g|]
}�|��Sr-r-r.s  �rrz&order_future_lines.<locals>.<listcomp>Fs���7�7�7�a��q��7�7�7rc� ��g|]
}�|��Sr-r-r.s  �rrz&order_future_lines.<locals>.<listcomp>Is���9�9�9�a��q��9�9�9r)
�split�	enumerate�lstrip�sorted�dict�zip�ranger"�append�join)r�uufuture_line_numbers�future_line_numbers�builtins_line_numbersr&r+�uul�sorted_uufuture_lines�fl�sorted_future_lines�bl�sorted_builtins_lines�	new_linesrr/s              @r�order_future_linesrEs����
�J�J�t���E�N�N�i��.>�.>�N�N�N��>�>�I�e�,<�,<�>�>�>��B�B�i��.>�.>�B�B�B���;�;�=�=�D� � � �$B� � � �7�7�7�B�B�B��5�&�'�'�5�5�1D�+E�+E�E�E�E�@�F�E�E��:�:�:�:�$9�:�:�:�
;�
;�C� ��%:�C�!@�!@�A�A��	�7�7�7�7�#6�7�7�7�	8�	8�B��s�#6��;�;�<�<��	�9�9�9�9�#8�9�9�9�	:�	:�B� ��%:�B�!?�!?�@�@���I�
�3�u�:�:�
�
�'�'���%�%�%����2�1�5�6�6�6�6�
�%�
%�
%����0��3�4�4�4�4�
�'�
'�
'����2�1�5�6�6�6�6����U�1�X�&�&�&�&��9�9�Y���rc� �eZdZdZdd�Zd�ZdS)�VerboseCalledProcessErrorz�
    Like CalledProcessError, but it displays more information (message and
    script output) for diagnosing test failures etc.
    Nc�>�||_||_||_||_dS�N)�msg�
returncode�cmd�output)�selfrJrKrLrMs     r�__init__z"VerboseCalledProcessError.__init__`s"�����$����������rc�<�d|j|j|j|jfzS)Nz>Command '%s' failed with exit status %d
Message: %s
Output: %s)rLrKrJrM)rNs r�__str__z!VerboseCalledProcessError.__str__fs%��R��8�T�_�d�h���D�E�	FrrI)�__name__�
__module__�__qualname__�__doc__rOrQr-rrrGrG[sF������������F�F�F�F�FrrGc��eZdZdS)�
FuturizeErrorN�rRrSrTr-rrrWrWj��������DrrWc��eZdZdS)�PasteurizeErrorNrXr-rrr[r[mrYrr[c�z�eZdZdZd�Z		dd�Zdd�Zd�Z			dd	�Zd
�Z	dd�Z
dd
�Z			dd�Zde
jfd�ZdS)�CodeHandlerzt
    Handy mixin for test classes for writing / reading / futurizing /
    running .py files in the test suite.
    c��td��|_td��|_tjg|_t
j��tj	j
z|_tjd��}|r,dtj
��tjz|zi|_dSdtj
��i|_dS)zi
        The outputs from the various futurize stages should have the
        following headers:
        z�
        from __future__ import absolute_import
        from __future__ import division
        from __future__ import print_function
        a4
        from __future__ import absolute_import
        from __future__ import division
        from __future__ import print_function
        from __future__ import unicode_literals
        from future import standard_library
        standard_library.install_aliases()
        from builtins import *
        �
PYTHONPATHN)r�headers1�headers2�sys�
executable�interpreters�tempfile�mkdtemp�os�path�sep�tempdir�getenv�getcwd�pathsep�env)rN�pypaths  r�setUpzCodeHandler.setUpvs���&�'�
�
��
�&�'�
�
��
�!�^�,����'�)�)�B�G�K�7�����<�(�(���	3�$�b�i�k�k�B�J�&>��&G�H�D�H�H�H�$�b�i�k�k�2�D�H�H�Hr�r�FTc���|rt|��}|�|��|�||||���|���}|r |jD]}	|�|	���}
�|S)a�
        Converts the code block using ``futurize`` and returns the
        resulting code.

        Passing stages=[1] or stages=[2] passes the flag ``--stage1`` or
        ``stage2`` to ``futurize``. Passing both stages runs ``futurize``
        with both stages by default.

        If from3 is False, runs ``futurize``, converting from Python 2 to
        both 2 and 3. If from3 is True, runs ``pasteurize`` to convert
        from Python 3 to both 2 and 3.

        Optionally reformats the code block first using the reformat() function.

        If run is True, runs the resulting code under all Python
        interpreters in self.interpreters.
        )�stages�all_imports�from3�conservative)�interpreter)r�_write_test_script�_futurize_test_script�_read_test_scriptrd�_run_test_script)rNrrtrurv�reformat�runrwrMrx�_s           r�convertzCodeHandler.convert�s���&�	'� ��&�&�D�����%�%�%��"�"�&�k�).�\�	#�	K�	K�	K��'�'�)�)���	C�#�0�
C�
C���)�)�k�)�B�B����
rc���|r*|�|��}|�|��}t|t��r*t|t��s|�d��}t|t��r*t|t��s|�d��}|�t|�����|�����dS)a�
        Compares whether the code blocks are equal. If not, raises an
        exception so the test fails. Ignores any trailing whitespace like
        blank lines.

        If ignore_imports is True, passes the code blocks into the
        strip_future_imports method.

        If one code block is a unicode string and the other a
        byte-string, it assumes the byte-string is encoded as utf-8.
        �utf-8N)�strip_future_imports�
isinstance�bytes�decode�assertEqualrE�rstrip)rNrM�expected�ignore_importss    r�comparezCodeHandler.compare�s����	;��.�.�v�6�6�F��0�0��:�:�H��f�e�$�$�	,�Z��%�-H�-H�	,��]�]�7�+�+�F��h��&�&�	0�z�&�%�/H�/H�	0����w�/�/�H����+�F�M�M�O�O�<�<�!���*�*�	,�	,�	,�	,�	,rc�B�g}|�d��D]s}|�d��s\|�d��sG|�d��s2d|vs.d|vs*|�d��s|�|���td�|��S)a
        Strips any of these import lines:

            from __future__ import <anything>
            from future <anything>
            from future.<anything>
            from builtins <anything>

        or any line containing:
            install_hooks()
        or:
            install_aliases()

        Limitation: doesn't handle imports split across multiple lines like
        this:

            from __future__ import (absolute_import, division, print_function,
                                    unicode_literals)
        rrzfrom future zfrom builtins zinstall_hooks()zinstall_aliases()zfrom future.)r2rr9r:)rNrrMrs    rr�z CodeHandler.strip_future_imports�s���(���J�J�t�$�$�	$�	$�D��O�O�$=�>�>�
$����~�6�6�
$����'7�8�8�
$�)�D�0�0�*�d�2�2����~�6�6�3��
�
�d�#�#�#���y�y�� � � rc	���|�||||||���}	|rd|vr|jn|j}
nd}
t|��}|
|vrd}
|�|	|
|z|���dS)a<
        Convenience method that calls convert() and compare().

        Reformats the code blocks automatically using the reformat_code()
        function.

        If all_imports is passed, we add the appropriate import headers
        for the stage(s) selected to the ``expected`` code-block, so they
        needn't appear repeatedly in the test code.

        If ignore_imports is True, ignores the presence of any lines
        beginning:

            from __future__ import ...
            from future import ...

        for the purpose of the comparison.
        )rtrurvr~rwrr�)r�N)r�rar`rr�)rN�beforer�rtrur�rvr~rwrM�headers�reformatteds            r�
convert_checkzCodeHandler.convert_check�s���*���f�V��$)�s���O�O���	�'(�F�{�{�d�m�m��
�G�G��G�#�H�-�-���k�!�!��G����V�W�{�2�$2�	�	4�	4�	4�	4�	4rc�$�|j||fi|��dS)ze
        Convenience method to ensure the code is unchanged by the
        futurize process.
        N)r�)rNr�kwargss   r�	unchangedzCodeHandler.unchangeds'��
	���4��0�0��0�0�0�0�0r�mytestscript.pyc��t|t��r|�d��}tj|j|zdd���5}|�t|����ddd��dS#1swxYwYdS)z�
        Dedents the given code (a multiline string) and writes it out to
        a file in a temporary folder like /tmp/tmpUDCn7x/mytestscript.py.
        r��wt��encodingN)r�r�r��io�openrj�writer)rNr�filename�fs    rryzCodeHandler._write_test_script!s���
�d�E�"�"�	(��;�;�w�'�'�D�
�W�T�\�H�,�d�W�
E�
E�
E�	"��
�G�G�F�4�L�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�
#A:�:A>�A>c��tj|j|zdd���5}|���}ddd��n#1swxYwY|S)N�rtr�r�)r�r�rj�read)rNr�r��	newsources    rr{zCodeHandler._read_test_script,s���
�W�T�\�H�,�d�W�
E�
E�
E�	!�������I�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!��s�A�A�Ac��g}t|��}|r|�d��|rd}n]d}|dgkr|�d��n'|dgkr|�d��n
|ddgksJ�|r|�d��|j|z}tj|g|zd	|gz}		t|	t|j�
��}
n�#t$r�}t|��5}dd�
|	���d
d|jz�d|�dd|���z��}
ddd��n#1swxYwYd|vrtnt}t|d��sd|_||
|j|j|j����d}~wwxYw|
S)Nz
--all-importsz
pasteurize.pyzfuturize.pyrz--stage1rrz--stage2z--conservativez-w)�stderrrn�Error running the command � r�env=%s�
Contents of file �:

�----
%s
----�futurizerM�rM)�listr9rjrbrcrrrnr
r�r:r�rWr[�hasattrrMrKrL)rNr�rtrurvrw�params�script�fn�	call_argsrM�er�rJ�
ErrorClasss               rrzz!CodeHandler._futurize_test_script1s�����f�����	+��M�M�/�*�*�*��	0�$�F�F�"�F��!��}�}��
�
�j�)�)�)�)��A�3����
�
�j�)�)�)�)��!�Q��'�'�'�'��
0��
�
�.�/�/�/��\�H�
$���^�V�,�v�5��r�
�B�	�	H�!�)�F���I�I�I�F�F��!�	H�	H�	H��b���
�Q�Q�����+�+�+�+� �4�8�+�+�+����(�1�6�6�8�8�3�3�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�,6��+?�+?�-�-�_�J��1�h�'�'�
 �����*�S�!�,���a�h�G�G�G�G�����%	H����&�
s=�,C	�	
F�E?�"?D-�!E?�-D1	�1E?�4D1	�5A
E?�?Fc��|j|z}	t||g|jt���}n�#t$r�}t|��5}dd�||g���dd|jz�d|�dd|���z��}ddd��n#1swxYwYt|d	��sd|_	t||j|j|j	�
���d}~wwxYw|S)N)rnr�r�r�rr�r�r�r�rMr�)
rjrrnrr
r�r:r�r�rMrGrKrL)rNr�rxr�rMr�r�rJs        rr|zCodeHandler._run_test_script`sI���\�H�
$��	W�!�;��"3�&*�h�v�?�?�?�F�F��!�	W�	W�	W��b���
�Q�Q����+�r�!2�3�3�3�3� �4�8�+�+�+����(�1�6�6�8�8�3�3�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��1�h�'�'�
 ����+�C���q�u�Q�X�V�V�V�V�����!	W����"�
s9�+�
C�C�AB�C�B	�C�B	�<C�CN)rqFFTTF)T)rqFTFTF)r�)r�rqFFF)rRrSrTrUrpr�r�r�r�r�ryr{rzrbrcr|r-rrr]r]qs	��������)3�)3�)3�VEJ�6;�����<,�,�,�,�, !� !� !�DJO�<@�#(�!4�!4�!4�!4�F1�1�1�	"�	"�	"�	"�����
HN�7<�+0�-�-�-�-�^):�%(�^������rr]z#this test is known to fail on Py2.6c�<�ts|Stj|��SrI)r�unittest�expectedFailure��funcs r�expectedFailurePY3r�� �������#�D�)�)�)rc�<�ts|Stj|��SrI)rr�r�r�s r�expectedFailurePY26r��� �������#�D�)�)�)rc�<�ts|Stj|��SrI)r
r�r�r�s r�expectedFailurePY27r��r�rc�<�ts|Stj|��SrI)r	r�r�r�s r�expectedFailurePY2r��r�r�assertRaisesRegexc��t|ttf��r |s
Jd���tj|��}|�|��s(|pd}|�d|j�d|��}|�|���dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.zRegex didn't matchz: z not found in N)r��str�unicode�re�compile�search�pattern�failureException)rN�text�expected_regexrJs    r�assertRegexr��s����.�3��.�1�1�4��B�B�B�B�B�~���N�3�3��� � ��&�&�)��)�)��*-�#�#�~�/E�/E�/E�t�t�L���#�#�C�(�(�(�)�)rr�c�&�eZdZ		dd�Zd�Zd�ZdS)�_AssertRaisesBaseContextNc��||_||_|�2	|j|_n+#t$rt|��|_YnwxYwd|_t
|tt
f��rtj	|��}||_
d|_dSrI)r��	test_caserR�obj_name�AttributeErrorr�r�r�r�r�r�rJ)rNr�r��callable_objr�s     rrOz!_AssertRaisesBaseContext.__init__�s��� ��
�"����#�
2� ,� 5��
�
��!�
2�
2�
2� #�L� 1� 1��
�
�
�
2����!�D�M��n�u�c�l�3�3�	8��Z��7�7�N�,�������s��A�Ac�v�|j�|j|��}|j�|���rI)r��_formatMessagerJr�)rN�standardMsgrJs   r�
_raiseFailurez&_AssertRaisesBaseContext._raiseFailure�s1���n�+�+�D�H�k�B�B���n�-�-�c�2�2�2rc��|�|�dd��|_|S|5||i|��ddd��dS#1swxYwYdS)z�
        If callable_obj is None, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If callable_obj is not None, call it passing args and kwargs.
        NrJ)�poprJ)rN�namer��argsr�s     r�handlez_AssertRaisesBaseContext.handle�s������z�z�%��.�.�D�H��K�
�	*�	*��L�$�)�&�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�	8�<�<)NN)rRrSrTrOr�r�r-rrr�r��sL������9=� $����� 3�3�3�
*�
*�
*�
*�
*rr�c��eZdZdZd�Zd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.c��tj���D]}t|dd��ri|_�tjd���|_|j���|_tj	d|j
��|S)N�__warningregistry__T)�record�always)rb�modules�values�getattrr��warnings�catch_warnings�warnings_manager�	__enter__�simplefilterr�)rN�vs  rr�z_AssertWarnsContext.__enter__�s�����#�#�%�%�	+�	+�A��q�/��6�6�
+�(*��%�� (� 7�t� D� D� D����-�7�7�9�9��
���h��
�6�6�6��rc���|j�|||��|�dS	|jj}n$#t$rt|j��}YnwxYwd}|jD]s}|j}t||j��s�|�|}|j	�(|j	�
t|����s�R||_|j|_|j
|_
dS|�@|�d�|j	jt|������|jr0|�d�||j����dS|�d�|����dS)Nz"{}" does not match "{}"z{} not triggered by {}z{} not triggered)r��__exit__r�rRr�r�r��messager�r�r��warningr��linenor��formatr�r�)rN�exc_type�	exc_value�tb�exc_name�first_matching�m�ws        rr�z_AssertWarnsContext.__exit__�s�����&�&�x��B�?�?�?����F�	*��}�-�H�H���	*�	*�	*��4�=�)�)�H�H�H�	*��������
	�
	�A��	�A��a���/�/�
���%�!"���#�/��'�.�.�s�1�v�v�6�6�0���D�L��J�D�M��(�D�K��F�F��%����9�@�@��(�0�#�n�2E�2E� G� G�
H�
H�
H��=�	D����7�>�>�x�?C�}� N� N�
O�
O�
O�
O�
O�
���1�8�8��B�B�C�C�C�C�Cs�/�A�AN)rRrSrTrUr�r�r-rrr�r��s=������L�L�	�	�	� D� D� D� D� Drr�c�T�t|||��}|�d|||��S)a�Fail unless a warning of class warnClass is triggered
       by callable_obj when invoked with arguments args and keyword
       arguments kwargs.  If a different type of warning is
       triggered, it will not be handled: depending on the other
       warning filtering rules in effect, it might be silenced, printed
       out, or raised as an exception.

       If called with callable_obj omitted or None, will return a
       context object used like this::

            with self.assertWarns(SomeWarning):
                do_something()

       An optional keyword argument 'msg' can be provided when assertWarns
       is used as a context object.

       The context manager keeps a reference to the first matching
       warning as the 'warning' attribute; similarly, the 'filename'
       and 'lineno' attributes give you information about the line
       of Python code from which the warning was triggered.
       This allows you to inspect the warning after the assertion::

           with self.assertWarns(SomeWarning) as cm:
               do_something()
           the_warning = cm.warning
           self.assertEqual(the_warning.some_attribute, 147)
    �assertWarns)r�r�)rN�expected_warningr�r�r��contexts      rr�r��s.��8"�"2�D�,�G�G�G��>�>�-��t�V�D�D�Drr�rI),�
__future__rrrgrer�rbr�r�r��textwrapr�future.utilsrrrr	r
�future.moves.subprocessrrr
�	unittest2rrErGrWr[�TestCaser]�skipIf�skip26r�r�r�r�r��assertRaisesRegexpr�r��objectr�r�r�r-rr�<module>rs!��6�6�6�6�6�6�6�6�	�	�	�	���������
�
�
�
�	�	�	�	�����	�	�	�	�������:�:�:�:�:�:�:�:�:�:�:�:�:�:�L�L�L�L�L�L�L�L�L�L��!� � � � ����= �= �= �@
F�
F�
F�
F�
F� 2�
F�
F�
F�	�	�	�	�	�-�	�	�	�	�	�	�	�	�/�	�	�	�G�G�G�G�G�(�#�G�G�G�V
����D�	E�	E��*�*�*�
*�*�*�*�*�*�*�*�*��w�x� �"5�6�6�O�*2�*;�*N�H��'�)�)�)�)��w�x� �-�0�0�?��K��!�=�+�>�>�>� *� *� *� *� *�v� *� *� *�D.D�.D�.D�.D�.D�2�.D�.D�.D�bE�E�E�E�>�w�x� �-�0�0�?��K��!�=�+�>�>�>�>�>�?�?r