403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/IPython/testing/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

�@�c7��6�dZddlZddlmZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZd
dlmZd
dlmZej dkrej!nej"Z#e#d���Z$d�Z%de%_&d�Z'd�Z(d*d�Z)d+d�Z*		d,d�Z+Gd�dej,��Z-dZ.d�Z/eZ0e1ej2d����Z3dZ4Gd �d!e5��Z6d"Z7Gd#�d$e6��Z8e	d%���Z9e	d&���Z:d'�Z;d-d(�Z<d-d)�Z=dS).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|��}tj�|��d��fd�|D��S)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']
    rc�P��g|]"}tj��|����#S�)�os�path�join)�.0�f�bases  ��7/usr/lib/python3/dist-packages/IPython/testing/tools.py�
<listcomp>zfull_path.<locals>.<listcomp>Hs)���2�2�2�a�R�W�\�\�$�q�
!�
!�2�2�2�)rrr�split)�	startPath�filesrs  @r�	full_pathr"&sE���@
����E�
�7�=�=��#�#�A�&�D�2�2�2�2�5�2�2�2�2rc��tjd|tj��}|r(t|�d����}d}||fStjd|tj��}|r(d}t|�d����}||fStjd|tj��}|rHt|�d����}t|�d����}||fSdS)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_outputr0Ks���&
�I�1�3���E�E�E����5�;�;�q�>�>�"�"�����e���
�Y�4�c�2�<�
H�
H�F�
�����F�L�L��O�O�$�$���e���
�Y�B�C��|�%�%�F�
���6�<�<��?�?�#�#���F�L�L��O�O�$�$���e����4rFc�
�gd�S)zEReturn a valid default argv for creating testing instances of ipython)z--quickz--colors=NoColorz--no-term-titlez--no-bannerz--autocall=0rrrr�default_argvr2ys�����rc��t��}d|j_d|j_d|j_t
jdd���}t|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_configrE�sr��
�X�X�F�-6�F�#�*�9?�F�+�6�/0�F�#�,��#�+>�u�M�M�M�A�&*�1�6�l�l�F��#��G�G�I�I�I�*/�F��'��Mrc�R�tjddg}|rd�|��}|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_cmdrM�s1���>�4��3�K��,��h�h�{�+�+���rrc�&�d}|�g}t��|z}tj�t��}t��}tj�||��}||zd|gz}tj���}	d|	d<|	�	dd��|	�
��D]*\}
}t|t��st|
|���+t|ttt|	���}|�t#jd�|����pd�	��\}
}t#j|
��t#j|��}}
|
rt)jd
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�)r2rr�dirname�__file__rMr�environ�copy�pop�items�
isinstance�str�printrr�communicater�encode�decoder%�sub)�fname�options�commands�__tracebackhide__�cmdargs�test_dirrL�
full_fname�full_cmdrU�k�v�p�out�errs               r�ipexecrs�sk��.�������n�n�w�&�G��w���x�(�(�H�!�#�#�K�����h��.�.�J��W�$��j�'9�9�H�
�*�/�/�
�
�C�%�C����G�G��d�#�#�#��	�	�������1��!�S�!�!�	��!�Q�K�K�K��
�h�t�D��#�F�F�F�A��}�}�9�#3�D�I�I�h�4G�4G�#H�#H�#P�D�}�Q�Q�H�C�����$�$�i�&6�s�&;�&;��C��/��f�_�b�#�.�.����8�OrrXc�>�d}t|||��\}}|r�|rwd�|��������d�|��������ksJ�nt	d|�d|�����d�|��������d�|��������ksJ�dS)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
    TrVz
Running file z produced error: N)rsr�strip�
splitlines�
ValueError)rf�expected_out�expected_errrgrhrirqrrs        r�ipexec_validaterz�s,��4���e�W�h�/�/�H�C��
�+��	+��9�9�S�Y�Y�[�[�3�3�5�5�6�6�$�)�)��"�"�$�$�/�/�1�1�;�;�������*�#�e�e�S�S�*�+�+�
+��9�9�S�Y�Y�[�[�+�+�-�-�.�.�$�)�)������'�'�)�)�3�3������rc�,�eZdZdZdd�Zd�Zd�Zd�ZdS)	�
TempFileMixinzcUtility class to create temporary Python/IPython files.

    Meant as a mixin class for test cases.�.pyc��t||��}t|d��sg|_|j�|��||_dS)zMake a valid python temp file.�tmpsN)r�hasattrr�appendrf)�self�src�extrfs    r�mktmpzTempFileMixin.mktmpsK���C��%�%���t�V�$�$�	��D�I��	���������
�
�
rc�v�t|d��r&|jD] }	tj|���#Y�xYwdSdS)Nr)r�rr�unlink)r�rfs  r�tearDownzTempFileMixin.tearDownsc���4�� � �		���
�
����I�e�$�$�$�$����D����		�		�
�
s�0�4c��|S�Nr�r�s r�	__enter__zTempFileMixin.__enter__%s���rc�.�|���dSr�)r�)r��exc_type�	exc_value�	tracebacks    r�__exit__zTempFileMixin.__exit__(s���
�
�����rN)r})�__name__�
__module__�__qualname__�__doc__r�r�r�r�rrrr|r|
s_������.�.���������������rr|z8Testing {0}

In:
  {1!r}
Expected:
  {2!r}
Got:
  {3!r}
c	���d}t|dt|dd����}|D];\}}||��}||ks%Jt�||||������<dS)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�pairsrir?�inp�expectedrqs       r�check_pairsr�3s~�� ���4��g�d�J��&L�&L�M�M�D��O�O�
��X��d�3�i�i���h����
� 4� 4�T�3��#� N� N�����O�OrzEDid not find {0!r} in printed output (on {1}):
-------
{2!s}
-------
c�&�eZdZdZdd�Zd�Zd�ZdS)	�AssertPrintsz�Context manager for testing that code prints certain text.

    Examples
    --------
    >>> with AssertPrints("abc", suppress=False):
    ...     print("abcd")
    ...     print("def")
    ...
    abcd
    def
    rRTc��||_t|jttf��r
|jg|_||_||_dSr�)�sr_r`�_re_type�channel�suppress)r�r�r�r�s    r�__init__zAssertPrints.__init__as>������d�f�s�H�o�.�.�	��f�X�D�F���� ��
�
�
rc��tt|j��|_t	��|_t
|j|j���|_tt|j|j	r|jn|j��dS)N)r�)
r�rIr��orig_stream�
MyStringIO�bufferr
�tee�setattrr�r�s rr�zAssertPrints.__enter__hsb��"�3���5�5��� �l�l����t�{�D�L�9�9�9�����T�\�$�-�#M�4�;�;�T�X�N�N�N�N�Nrc�|�d}	|�	|j���dS|j���tt|j|j��|j���}|j	D]�}t|t��rD|�|��s.Jt�|j|j|������[||vs)Jt�||j|�������	|j���dS#|j���wxYw�NTF)r�rB�flushr�rIr�r�r��getvaluer�r_r�r&�notprinted_msgr��pattern�r��etype�valuer�ri�printedr�s       rr�zAssertPrints.__exit__ns+�� ��	�� ��
�H�N�N������
�H�N�N�����C���t�'7�8�8�8��k�*�*�,�,�G��V�
Y�
Y���a��*�*�Y��8�8�G�,�,�e�e�n�.C�.C�A�I�t�|�]d�.e�.e�e�e�e�e���<�<�<��)>�)>�q�$�,�PW�)X�)X�<�<�<�<���H�N�N�������D�H�N�N�������s�D �C"D � D;N)rRT)r�r�r�r�r�r�r�rrrr�r�UsS������
�
�!�!�!�!�O�O�O�����rr�z>Found {0!r} in printed output (on {1}):
-------
{2!s}
-------
c��eZdZdZd�ZdS)�AssertNotPrintszcContext manager for checking that certain output *isn't* produced.

    Counterpart of AssertPrintsc��d}	|�5|j���	|j���dS|j���tt|j|j��|j���}|j	D]�}t|t��rD|�|��r.Jt�|j|j|������[||vs)Jt�||j|�������	|j���dS#|j���wxYwr�)r�rBr�r�rIr�r�r�r�r�r_r�r&�printed_msgr�r�r�s       rr�zAssertNotPrints.__exit__�sW�� ��	�� ����� � � ��
�H�N�N������
�H�N�N�����C���t�'7�8�8�8��k�*�*�,�,�G��V�
2�
2���a��*�*�2� �x�x��0�0�:�:��1C�1C��	�4�<��2:�2:�:�:�:�:��G�+�+�+�[�-?�-?��4�<��.2�.2�+�+�+�+���H�N�N�������D�H�N�N�������s�D9�C"D9�9EN)r�r�r�r�r�rrrr�r��s-������#�#�����rr�c#�dK�ddlm}|j}d�|_	dV�||_dS#||_wxYw)Nr)�warnc��dSr�r)�a�kws  r�<lambda>zmute_warn.<locals>.<lambda>�s���r)�
IPython.utilsr�)r��	save_warns  r�	mute_warnr��sU����"�"�"�"�"�"��	�I�%�%�D�I��
������	�	�	��I��	����s�&�	/c#�K�t|dd������	dV�tj|��dS#tj|��wxYw)zGCreate an empty, named, temporary file for the duration of the context.�wzutf-8)�encodingN)�openrBrr�)r?s r�
make_tempfiler��sZ����	��s�W�%�%�%�+�+�-�-�-��
����
�	�$��������	�$�������s�A�Ac�N��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.
    rXc�h��	t���S#t$r}td��|�d}~wwxYw)NzNo more inputs given)�next�
StopIteration�EOFError)�prompt�e�its  �r�
mock_inputzfake_input.<locals>.mock_input�sC���	:���8�8�O���	:�	:�	:��1�2�2��9�����	:���s��
1�,�1zbuiltins.input�rX)�iterr)�inputsr�r�s  @r�
fake_inputr��sA���
�f���B�:�:�:�:�:�:��!�:�.�.�.rc��t��|dgz}t|��\}}}|dks
J|���d|vsJ�d|vsJ�d|vsJ�||fS)z)test that `ipython [subcommand] -h` worksz-hr�	Traceback�Options�
--help-all�rMr
��
subcommand�cmdrqrr�rcs     r�help_output_testr��sy��
�
�
�z�4�0�
0�C�(��-�-�L�C��b�
��7�7�7�C�7�7�7��c�!�!�!�!��������3�������8�Orc��t��|dgz}t|��\}}}|dks
J|���d|vsJ�d|vsJ�d|vsJ�||fS)z1test that `ipython [subcommand] --help-all` worksr�rr�r��Classr�r�s     r�help_all_output_testr��su��
�
�
�z�<�8�
8�C�(��-�-�L�C��b�
��7�7�7�C�7�7�7��c�!�!�!�!��������c�>�>�>�>���8�Orr5)Nr)rXNrr�)>r�r�pathlibrr%rIr=�unittest�
contextlibr�ior�
subprocessrr�
unittest.mockr�traitlets.config.loaderr	�IPython.utils.processr
�IPython.utils.textr�IPython.utils.iorr
r�rrXr�decr�platform�skip_doctest�	null_deco�doctest_decor"r0�__test__r2rErMrsrz�TestCaser|r�r�r��type�compiler�r��objectr�r�r�r�r�r�r�r�rrr�<module>r�s����
�	�	�	�������	�	�	�	�
�
�
�
���������%�%�%�%�%�%�������"�"�"�"�"�"�"�"�������*�*�*�*�*�*�7�7�7�7�7�7�+�+�+�+�+�+�-�-�-�-�-�-�-�-�#�#�#�#�#�#�������������
,/�<�7�+B�+B�{�'�'��
��
�!3�!3���!3�H'�'�'�V#������
�
�
�����$7�7�7�7�t79�+-�,�,�,�,�^�����H�%����D�
�O�O�O�0�
��4�
��
�3��� � ����*�*�*�*�*�6�*�*�*�X�������l����4������������/�/�/�(���������r

Youez - 2016 - github.com/yon3zu
LinuXploit