https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/future/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/future/tests/__pycache__/base.cpython-310.pyc
o

,�]�M�@s�ddlmZmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZerHddlZdd�Zdd	�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�dej�Ze�ed�Zdd�Z dd�Z!dd�Z"dd�Z#e$ejd�s�ejj%ej_&d$dd�Z'e$ejd�s�e
ejde'�Gdd�de(�Z)Gd d!�d!e)�Z*d$d"d#�Z+e$ejd#�s�e
ejd#e+�dSdS)%�)�print_function�absolute_importN)�dedent)�bind_method�PY26�PY3�PY2�PY27)�check_output�STDOUT�CalledProcessErrorcCs|�d�r|dd�}t|�S)z,
    Removes any leading 
 and dedents.
    �
�N)�
startswithr)�code�r�3/usr/lib/python3/dist-packages/future/tests/base.py�
reformat_codes
rcs^|�d��dd�t��D�}dd�t��D�}dd�t��D�}|��|ks*Jd��dd�}d	d
�}||�||�ks>Jd��t�fdd�|D��}tt||��}t�fd
d�|D��}tt||��}	t�fdd�|D��}
tt||
��}g}tt���D]-}
|
|vr�|�||
�q||
|vr�|�|	|
�q||
|vr�|�||
�q||��|
�q|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.
    r
cS�g|]\}}|�d�r|�qS)�from __future__ import �r��.0�i�linerrr�
<listcomp>*�
�z&order_future_lines.<locals>.<listcomp>cSs(g|]\}}|�d�s|�d�r|�qS)zfrom futurez	from pastrrrrrr-s
�
�cSr)z
from builtinsrrrrrr1rzIinternal usage error: dedent the code before calling order_future_lines()cSst|�dkr
t|�SdS)Nr)�len�max��numbersrrr�mymax7sz!order_future_lines.<locals>.mymaxcSst|�dkr
t|�Std�S)Nr�inf)r�min�floatrrrr�mymin:sz!order_future_lines.<locals>.myminz2the __future__ and future imports are out of orderc�g|]}�|�qSrr�rr��linesrrrC�cr&rrr'r(rrrFr*cr&rrr'r(rrrIr*)
�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_linesrrr(r�order_future_liness4

�
r>c@s"eZdZdZddd�Zdd�ZdS)�VerboseCalledProcessErrorz�
    Like CalledProcessError, but it displays more information (message and
    script output) for diagnosing test failures etc.
    NcCs||_||_||_||_dS�N)�msg�
returncode�cmd�output)�selfrArBrCrDrrr�__init__`s
z"VerboseCalledProcessError.__init__cCsd|j|j|j|jfS)Nz>Command '%s' failed with exit status %d
Message: %s
Output: %s)rCrBrArD)rErrr�__str__fs�z!VerboseCalledProcessError.__str__r@)�__name__�
__module__�__qualname__�__doc__rFrGrrrrr?[s
r?c@�eZdZdS)�
FuturizeErrorN�rHrIrJrrrrrMj�rMc@rL)�PasteurizeErrorNrNrrrrrPmrOrPc@s�eZdZdZdd�Z		ddd�Zdd	d
�Zdd�Z			dd
d�Zdd�Z	ddd�Z
ddd�Z			ddd�Zde
jfdd�ZdS) �CodeHandlerzt
    Handy mixin for test classes for writing / reading / futurizing /
    running .py files in the test suite.
    cCsltd�|_td�|_tjg|_t��tj	j
|_t�d�}|r-dt�
�tj|i|_dSdt�
�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)rE�pypathrrr�setUpvs


	
zCodeHandler.setUp�r�FTcCsP|rt|�}|�|�|j||||d�|��}|r&|jD]}	|j|	d�}
q|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_scriptrW�_run_test_script)rErrfrgrh�reformat�runrirDrj�_rrr�convert�s
�
zCodeHandler.convertcCsp|r|�|�}|�|�}t|t�rt|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�assertEqualr>�rstrip)rErD�expected�ignore_importsrrr�compare�s



�zCodeHandler.comparecCs`g}|�d�D]#}|�d�s*|�d�s*|�d�s*d|vs*d|vs*|�d�s*|�|�qd�|�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)
        r
rzfrom future zfrom builtins zinstall_hooks()zinstall_aliases()zfrom future.)r+rr2r3)rErrDrrrrrt�s
���
�
z CodeHandler.strip_future_importsc	Cs`|j||||||d�}	|rd|vr|jn|j}
nd}
t|�}|
|vr$d}
|j|	|
||d�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.
        )rfrgrhrprire�)r{N)rrrTrSrr|)rE�beforerzrfrgr{rhrprirD�headers�reformattedrrr�
convert_check�s
�
�zCodeHandler.convert_checkcKs|j||fi|��dS)ze
        Convenience method to ensure the code is unchanged by the
        futurize process.
        N)r�)rEr�kwargsrrr�	unchangedszCodeHandler.unchanged�mytestscript.pycCs^t|t�r
|�d�}tj|j|ddd��}|�t|��Wd�dS1s(wYdS)z�
        Dedents the given code (a multiline string) and writes it out to
        a file in a temporary folder like /tmp/tmpUDCn7x/mytestscript.py.
        rs�wt��encodingN)rurvrw�io�openr]�writer)rEr�filename�frrrrk!s


"�zCodeHandler._write_test_scriptcCsDtj|j|ddd��
}|��}Wd�|S1swY|S)N�rtrsr�)r�r�r]�read)rEr�r��	newsourcerrrrm,s

��zCodeHandler._read_test_scriptcCsDg}t|�}|r
|�d�|rd}n'd}|dgkr|�d�n|dgkr*|�d�n|ddgks2J�|r9|�d�|j|}tj|g|d	|g}	zt|	t|jd
�}
W|
Sty�}zAt	|��}dd�
|	�d
|j|d|��f}
Wd�n1s}wYd|vr�tnt
}t|d�s�d|_||
|j|j|jd��d}~ww)Nz
--all-importsz
pasteurize.pyzfuturize.pyrz--stage1rez--stage2z--conservativez-w)�stderrra�8Error running the command %s
%s
Contents of file %s:

%s� �env=%s�----
%s
----�futurizerD�rD)�listr2r]rUrVr
rrarr�r3r�rMrP�hasattrrDrBrC)rEr�rfrgrhri�params�script�fn�	call_argsrD�er�rA�
ErrorClassrrrrl1sF




�

���
��z!CodeHandler._futurize_test_scriptcCs�|j|}z
t||g|jtd�}W|StyY}z;t|��}dd�||g�d|j|d|��f}Wd�n1s=wYt|d�sJd|_	t
||j|j|j	d��d}~ww)N)rar�r�r�r�r�rDr�)
r]r
rarrr�r3r�r�rDr?rBrC)rEr�rjr�rDr�r�rArrrrn`s*
��

���
��zCodeHandler._run_test_scriptN)rdFFTTF)T)rdFTFTF)r�)r�rdFFF)rHrIrJrKrcrrr|rtr�r�rkrmrlrUrVrnrrrrrQqs,+
�
"
�#


�/�rQz#this test is known to fail on Py2.6cC�ts|St�|�Sr@)r�unittest�expectedFailure��funcrrr�expectedFailurePY3�
r�cCr�r@)rr�r�r�rrr�expectedFailurePY26�r�r�cCr�r@)r	r�r�r�rrr�expectedFailurePY27�r�r�cCr�r@)rr�r�r�rrr�expectedFailurePY2�r�r��assertRaisesRegexcCsTt|ttf�r|s
Jd��t�|�}|�|�s(|pd}d||j|f}|�|��dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.zRegex didn't matchz%s: %r not found in %rN)ru�str�unicode�re�compile�search�pattern�failureException)rE�text�expected_regexrArrr�assertRegex�s


�r�c@s*eZdZ		ddd�Zdd�Zdd�ZdS)	�_AssertRaisesBaseContextNcCsl||_||_|durz|j|_Wntyt|�|_Ynwd|_t|ttf�r.t�	|�}||_
d|_dSr@)rz�	test_caserH�obj_name�AttributeErrorr�rurvr�r�r�rA)rErzr��callable_objr�rrrrF�s�

z!_AssertRaisesBaseContext.__init__cCs|j�|j|�}|j�|��r@)r��_formatMessagerAr�)rE�standardMsgrArrr�
_raiseFailure�sz&_AssertRaisesBaseContext._raiseFailurecCsR|dur
|�dd�|_|S|�||i|��Wd�dS1s"wYdS)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.
        NrA)�poprA)rE�namer��argsr�rrr�handle�s"�z_AssertRaisesBaseContext.handle)NN)rHrIrJrFr�r�rrrrr��s
�r�c@s eZdZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.cCsNtj��D]}t|dd�ri|_qtjdd�|_|j��|_t�	d|j
�|S)N�__warningregistry__T)�record�always)rU�modules�values�getattrr��warnings�catch_warnings�warnings_manager�	__enter__�simplefilterrz)rE�vrrrr��s�z_AssertWarnsContext.__enter__cCs|j�|||�|durdSz|jj}Wnty"t|j�}Ynwd}|jD]-}|j}t||j�s4q(|dur:|}|j	durH|j	�
t|��sHq(||_|j|_|j
|_
dS|durg|�d�|j	jt|���|jrv|�d�||j��dS|�d�|��dS)Nz"{}" does not match "{}"z{} not triggered by {}z{} not triggered)r��__exit__rzrHr�r�r��messagerur�r��warningr��linenor��formatr�r�)rE�exc_type�	exc_value�tb�exc_name�first_matching�m�wrrrr��s@�

��

�z_AssertWarnsContext.__exit__N)rHrIrJrKr�r�rrrrr��sr�cOst|||�}|�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�)rE�expected_warningr�r�r��contextrrrr��sr�r@),�
__future__rrrZrXr�rUr�r�r��textwrapr�future.utilsrrrrr	�future.moves.subprocessr
rr�	unittest2rr>r?rMrP�TestCaserQ�skipIf�skip26r�r�r�r�r��assertRaisesRegexpr�r��objectr�r�r�rrrr�<module>sJ	@


"
1�

https://t.me/RX1948 - 2025