403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.52
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/IPython/testing/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/IPython/testing/__pycache__/tools.cpython-312.pyc
�

}�e7��4�dZddlZddlmZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZd
dlmZd
dlmZej@dk(rejBnejDZ#e#d��Z$d�Z%de%_&d�Z'd�Z(d)d�Z)d*d�Z*		d+d�Z+Gd�dejX�Z-dZ.d�Z/eZ0e1ejdd��Z3dZ4Gd�d e5�Z6d!Z7Gd"�d#e6�Z8e	d$��Z9e	d%��Z:d&�Z;d,d'�Z<d,d(�Z=y)-zWGeneric testing tools.

Authors
-------
- Fernando Perez <Fernando.Perez@berkeley.edu>
�N)�Path)�contextmanager)�StringIO)�Popen�PIPE)�patch)�Config)�get_output_error_code)�list_strings)�temp_pyfile�Tee)�	py3compat�)�
decorators)�skipdoctest�win32c���t|�}tjj|�d}|D�cgc]"}tjj	||���$c}Scc}w)aPMake full paths for all the listed files, based on startPath.

    Only the base part of startPath is kept, since this routine is typically
    used with a script's ``__file__`` variable as startPath. The base of startPath
    is then prepended to all the listed files, forming the output list.

    Parameters
    ----------
    startPath : string
      Initial path to use as the base for the results.  This path is split
      using os.path.split() and only its first component is kept.

    files : string or list
      One or more files.

    Examples
    --------

    >>> full_path('/foo/bar.py',['a.txt','b.txt'])
    ['/foo/a.txt', '/foo/b.txt']

    >>> full_path('/foo',['a.txt','b.txt'])
    ['/a.txt', '/b.txt']

    If a single file is given, the output is still a list::

        >>> full_path('/foo','a.txt')
        ['/a.txt']
    r)r�os�path�split�join)�	startPath�files�base�fs    �7/usr/lib/python3/dist-packages/IPython/testing/tools.py�	full_pathr&sI��@
���E�
�7�7�=�=��#�A�&�D�+0�2�a�R�W�W�\�\�$�q�
!�2�2��2s�'Ac���tjd|tj�}|r t|j	d��}d}||fStjd|tj�}|r d}t|j	d��}||fStjd|tj�}|r8t|j	d��}t|j	d��}||fSy)aParse the output of a test run and return errors, failures.

    Parameters
    ----------
    txt : str
      Text output of a test run, assumed to contain a line of one of the
      following forms::

        'FAILED (errors=1)'
        'FAILED (failures=1)'
        'FAILED (errors=1, failures=1)'

    Returns
    -------
    nerr, nfail
      number of errors and failures.
    z^FAILED \(errors=(\d+)\)rrz^FAILED \(failures=(\d+)\)z(^FAILED \(errors=(\d+), failures=(\d+)\)�)rr)�re�search�	MULTILINE�int�group)�txt�err_m�nerr�nfail�fail_m�both_ms      r�parse_test_outputr+Ks���&
�I�I�1�3����E�E���5�;�;�q�>�"�����e���
�Y�Y�4�c�2�<�<�
H�F�
����F�L�L��O�$���e���
�Y�Y�B�C��|�|�%�F�
��6�<�<��?�#���F�L�L��O�$���e����Fc�
�gd�S)zEReturn a valid default argv for creating testing instances of ipython)z--quickz--colors=NoColorz--no-term-titlez--no-bannerz--autocall=0�r.r,r�default_argvr/ys���r,c�8�t�}d|j_d|j_d|j_t
jdd��}t|j�|j_|j�d|j_
|S)z6Return a config object with good defaults for testing.�NoColor�Frztest_hist.sqliteF)�suffix�deletei')r	�TerminalInteractiveShell�colors� TerminalTerminalInteractiveShell�
term_title�autocall�tempfile�NamedTemporaryFiler�name�HistoryManager�	hist_file�close�
db_cache_size)�configrs  r�default_configrB�sx��
�X�F�-6�F�#�#�*�9?�F�+�+�6�/0�F�#�#�,��#�#�+>�u�M�A�&*�1�6�6�l�F���#��G�G�I�*/�F���'��Mr,c�R�tjddg}|rdj|�}|S)aW
    Return appropriate IPython command line name. By default, this will return
    a list that can be used with subprocess.Popen, for example, but passing
    `as_string=True` allows for returning the IPython command as a string.

    Parameters
    ----------
    as_string: bool
        Flag to allow to return the command as a string.
    z-m�IPython� )�sys�
executabler)�	as_string�ipython_cmds  r�get_ipython_cmdrJ�s+���>�>�4��3�K���h�h�{�+���r,c���d}|�g}t�|z}tjjt�}t�}tjj
||�}||zd|gz}tjj�}	d|	d<|	jdd�|	j�D]"\}
}t|t�r�t|
|��$t|ttt|	��}|j!t#j$dj
|��xsd�	�\}
}t#j&|
�t#j&|�}}
|
rt)j*d
d|
�}
|
|fS)aUtility to call 'ipython filename'.

    Starts IPython with a minimal and safe configuration to make startup as fast
    as possible.

    Note that this starts IPython in a subprocess!

    Parameters
    ----------
    fname : str, Path
      Name of file to be executed (should have .py or .ipy extension).

    options : optional, list
      Extra command-line flags to be passed to IPython.

    commands : optional, list
      Commands to send in on stdin

    Returns
    -------
    ``(stdout, stderr)`` of ipython subprocess.
    TNz--�ignore�PYTHONWARNINGS�PYCHARM_HOSTED)�stdout�stderr�stdin�env�
)�inputz\x1b\[[^h]+h�)r/rr�dirname�__file__rJr�environ�copy�pop�items�
isinstance�str�printrr�communicater�encode�decoder �sub)�fname�options�commands�__tracebackhide__�cmdargs�test_dirrI�
full_fname�full_cmdrR�k�v�p�out�errs               r�ipexecrp�s>��.�������n�w�&�G��w�w���x�(�H�!�#�K������h��.�J��W�$��j�'9�9�H�
�*�*�/�/�
�C�%�C����G�G��d�#��	�	�����1��!�S�!��!�Q�K�	�
	�h�t�D��#�F�A��}�}�9�#3�#3�D�I�I�h�4G�#H�#P�D�}�Q�H�C������$�i�&6�&6�s�&;��C���f�f�_�b�#�.����8�Or,rUc���d}t|||�\}}|rp|r]dj|j�j��dj|j�j��k(sJ�t	d|�d|����dj|j�j��dj|j�j��k(sJ�y)a9Utility to call 'ipython filename' and validate output/error.

    This function raises an AssertionError if the validation fails.

    Note that this starts IPython in a subprocess!

    Parameters
    ----------
    fname : str, Path
      Name of the file to be executed (should have .py or .ipy extension).

    expected_out : str
      Expected stdout of the process.

    expected_err : optional, str
      Expected stderr of the process.

    options : optional, list
      Extra command-line flags to be passed to IPython.

    Returns
    -------
    None
    TrSz
Running file z produced error: N)rpr�strip�
splitlines�
ValueError)rc�expected_out�expected_errrdrerfrnros        r�ipexec_validaterw�s���4���e�W�h�/�H�C��
���9�9�S�Y�Y�[�3�3�5�6�$�)�)��"�"�$�/�/�1�;��
���#�S�*�+�
+��9�9�S�Y�Y�[�+�+�-�.�$�)�)�����'�'�)�3���r,c�*�eZdZdZdd�Zd�Zd�Zd�Zy)�
TempFileMixinzcUtility class to create temporary Python/IPython files.

    Meant as a mixin class for test cases.c��t||�}t|d�sg|_|jj|�||_y)zMake a valid python temp file.�tmpsN)r�hasattrr{�appendrc)�self�src�extrcs    r�mktmpzTempFileMixin.mktmps8���C��%���t�V�$��D�I��	�	�������
r,c�z�t|d�r(|jD]}	tj|��yy#Y�!xYw)Nr{)r|r{r�unlink)r~rcs  r�tearDownzTempFileMixin.tearDownsC���4�� ����
����I�I�e�$�	
�!����s�6�:c��|S�Nr.�r~s r�	__enter__zTempFileMixin.__enter__%s���r,c�$�|j�yr�)r�)r~�exc_type�	exc_value�	tracebacks    r�__exit__zTempFileMixin.__exit__(s���
�
�r,N)z.py)�__name__�
__module__�__qualname__�__doc__r�r�r�r�r.r,rryry
s��.����r,ryz8Testing {0}

In:
  {1!r}
Expected:
  {2!r}
Got:
  {3!r}
c	��d}t|dt|dd��}|D]/\}}||�}||k(r�Jtj||||���y)a�Utility function for the common case of checking a function with a
    sequence of input/output pairs.

    Parameters
    ----------
    func : callable
      The function to be tested. Should accept a single argument.
    pairs : iterable
      A list of (input, expected_output) tuples.

    Returns
    -------
    None. Raises an AssertionError if any output does not match the expected
    value.
    T�	func_namer�z	<unknown>N)�getattr�
pair_fail_msg�format)�func�pairsrfr<�inp�expectedrns       r�check_pairsr�3sa�� ���4��g�d�J��&L�M�D��O�
��X��3�i���h��N�
� 4� 4�T�3��#� N�N��Or,zEDid not find {0!r} in printed output (on {1}):
-------
{2!s}
-------
c�$�eZdZdZdd�Zd�Zd�Zy)�AssertPrintsz�Context manager for testing that code prints certain text.

    Examples
    --------
    >>> with AssertPrints("abc", suppress=False):
    ...     print("abcd")
    ...     print("def")
    ...
    abcd
    def
    c��||_t|jttf�r|jg|_||_||_yr�)�sr\r]�_re_type�channel�suppress)r~r�r�r�s    r�__init__zAssertPrints.__init__as6������d�f�f�s�H�o�.��f�f�X�D�F���� ��
r,c�0�tt|j�|_t	�|_t
|j
|j��|_tt|j|jr|j
�y|j�y)N)r�)
r�rFr��orig_stream�
MyStringIO�bufferr
�tee�setattrr�r�s rr�zAssertPrints.__enter__hsW��"�3����5��� �l����t�{�{�D�L�L�9�����T�\�\�$�-�-�4�;�;�N�T�X�X�Nr,c��d}	|�	|jj�y|jj�tt|j
|j�|jj�}|jD]~}t|t�rB|j|�r�%Jtj|j|j
|���||vr�ZJtj||j
|���	|jj�y#|jj�wxYw�NTF)r�r?�flushr�rFr�r�r��getvaluer�r\r�r!�notprinted_msgr��pattern�r~�etype�valuer�rf�printedr�s       rr�zAssertPrints.__exit__ns��� ��	�� ��
�H�H�N�N��
�H�H�N�N���C����t�'7�'7�8��k�k�*�*�,�G��V�V�
Y���a��*��8�8�G�,�e�n�.C�.C�A�I�I�t�|�|�]d�.e�e�,���<�X��)>�)>�q�$�,�,�PW�)X�X�<�	
Y�
��H�H�N�N���D�H�H�N�N��s�D$�B	D$�,4D$�!'D$�$EN)rOT)r�r�r�r�r�r�r�r.r,rr�r�Us��
�!�O�r,r�z>Found {0!r} in printed output (on {1}):
-------
{2!s}
-------
c��eZdZdZd�Zy)�AssertNotPrintszcContext manager for checking that certain output *isn't* produced.

    Counterpart of AssertPrintsc��d}	|�6|jj�	|jj�y|jj�tt|j
|j�|jj�}|jD]~}t|t�rB|j|�s�%Jtj|j|j
|���||vr�ZJtj||j
|���	|jj�y#|jj�wxYwr�)r�r?r�r�rFr�r�r�r�r�r\r�r!�printed_msgr�r�r�s       rr�zAssertNotPrints.__exit__�s�� ��	�� ������ ��
�H�H�N�N��
�H�H�N�N���C����t�'7�'7�8��k�k�*�*�,�G��V�V�
2���a��*� �x�x��0�:��1C�1C��	�	�4�<�<��2:�:�0��G�+�2�[�-?�-?��4�<�<��.2�2�+�
2���H�H�N�N���D�H�H�N�N��s�D>�B	D>�4D>�;'D>�>EN)r�r�r�r�r�r.r,rr�r��s��#�r,r�c#�pK�ddlm}|j}d�|_	d��||_y#||_wxYw�w)Nr)�warnc��yr�r.)�a�kws  r�<lambda>zmute_warn.<locals>.<lambda>�s�r,)�
IPython.utilsr�)r��	save_warns  r�	mute_warnr��s/����"��	�	�I�%�D�I��
���	��I��	�s�6�*�6�	3�6c#�K�t|dd��j�	d��tj|�y#tj|�wxYw�w)zGCreate an empty, named, temporary file for the duration of the context.�wzutf-8)�encodingN)�openr?rr�)r<s r�
make_tempfiler��s;����	��s�W�%�+�+�-��
�
�	�	�$����	�	�$��s�A�:�A�A�Ac�>��t|��d�fd�	}td|�S)aTemporarily replace the input() function to return the given values

    Use as a context manager:

    with fake_input(['result1', 'result2']):
        ...

    Values are returned in order. If input() is called again after the last value
    was used, EOFError is raised.
    c�V��	t��S#t$r}td�|�d}~wwxYw)NzNo more inputs given)�next�
StopIteration�EOFError)�prompt�e�its  �r�
mock_inputzfake_input.<locals>.mock_input�s/���	:���8�O���	:��1�2��9��	:�s�
�	(�#�(zbuiltins.input�rU)�iterr)�inputsr�r�s  @r�
fake_inputr��s#���
�f��B�:��!�:�.�.r,c��t�|dgz}t|�\}}}|dk(sJ|��d|vsJ�d|vsJ�d|vsJ�||fS)z)test that `ipython [subcommand] -h` worksz-hr�	Traceback�Options�
--help-all�rJr
��
subcommand�cmdrnro�rcs     r�help_output_testr��sh��
�
�z�4�0�
0�C�(��-�L�C��b�
��7��C��7��c�!�!�!�������3������8�Or,c��t�|dgz}t|�\}}}|dk(sJ|��d|vsJ�d|vsJ�d|vsJ�||fS)z1test that `ipython [subcommand] --help-all` worksr�rr�r��Classr�r�s     r�help_all_output_testr��sf��
�
�z�<�8�
8�C�(��-�L�C��b�
��7��C��7��c�!�!�!�������c�>��>���8�Or,r2)Nr.)rUNr.r�)>r�r�pathlibrr rFr:�unittest�
contextlibr�ior�
subprocessrr�
unittest.mockr�traitlets.config.loaderr	�IPython.utils.processr
�IPython.utils.textr�IPython.utils.iorr
r�rrUr�decr�platform�skip_doctest�	null_deco�doctest_decorr+�__test__r/rBrJrprw�TestCaseryr�r�r��type�compiler�r��objectr�r�r�r�r�r�r�r�r.r,r�<module>r�s=���
��	�
���%��"��*�7�+�-�#���
,/�<�<�7�+B�{�'�'��
�
��
�!3��!3�H'�V#����
��$7�t79�+-�,�^�H�%�%��D�
�O�0�
��
��
�
�3�� ����*�6�*�X���l��4��������/�(�r,

Youez - 2016 - github.com/yon3zu
LinuXploit