????

Your IP : 18.220.124.7


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest/__pycache__/capture.cpython-311.pyc

�

�܋f���	�
�dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl%m'Z'ddl(m)Z)ddl(m*Z*ddl(m+Z+erddl,m-Z-dd l,m.Z.e.d!Z/d"e"d#dfd$�Z0d\d%�Z1d&ed#dfd'�Z2e d(�)��d*efd+���Z3Gd,�d-ej4��Z5Gd.�d/ej4��Z6Gd0�d1e6��Z7Gd2�d3e��Z8Gd4�d5ej9ee��Z:d6d7d8d9�Z;Gd:�d;e:e<��Z=Gd<�d=e:e��Z>Gd>�d?e>e?��Z@Gd@�dAe>e<��ZAGdB�dCe:e��ZBGdD�dEeBe?��ZCGdF�dGeBe<��ZDejEdHksereGdI�dJeee����ZFn&GdK�dJejGdJdLdMg��ee��ZFGdN�dOee��ZHdPdQd#eHe<fdR�ZIGdS�dT��ZJGdU�dVee��ZKe&dWe'd#eeKe<ddffdX���ZLe&dWe'd#eeKe?ddffdY���ZMe&dWe'd#eeKe<ddffdZ���ZNe&dWe'd#eeKe?ddffd[���ZOdS)]z+Per-test stdout/stderr capturing mechanism.�N��UnsupportedOperation)�
TemporaryFile)�
TracebackType)�Any)�AnyStr)�BinaryIO)�	Generator)�Generic)�Iterable)�Iterator)�List)�
NamedTuple)�Optional)�TextIO)�Tuple)�Type)�
TYPE_CHECKING)�Union)�final)�Config)�hookimpl)�Parser)�check_ispytest)�fixture)�
SubRequest)�	Collector)�File)�Item)�Final)�Literal��fd�sys�no�tee-sys�parser�returnc��|�d��}|�ddddgd�d���|�d	d
ddd
���dS)N�generalz	--capture�storer#�methodr"z3Per-test capturing method: one of fd|sys|no|tee-sys)�action�default�metavar�choices�helpz-s�store_constr%�capturezShortcut for --capture=no)r-�const�destr1)�getgroup�
_addoption)r'�groups  �`/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/_pytest/capture.py�pytest_addoptionr:-s����O�O�I�&�&�E�	�������.�.�.�
B�
����
������
�
(�������c�t�tj�d��r	ddl}dS#t$rYdSwxYwdS)aEnsure colorama is imported so that it attaches to the correct stdio
    handles on Windows.

    colorama uses the terminal on import time. So if something does the
    first import of colorama while I/O capture is active, colorama will
    fail in various ways.
    �win32rN)r$�platform�
startswith�colorama�ImportError)r@s r9�_colorama_workaroundrB@sZ���|���w�'�'��	��O�O�O�O�O���	�	�	��D�D�	�����s�'�
5�5�streamc����tj�d��rttd��rdSt|d��sdSt|jd����r|jjn|j}t
|tj��sdS�fd�}|tj	d��t_	|tj
d��t_
|tjd��t_dS)	a�Workaround for Windows Unicode console handling.

    Python 3.6 implemented Unicode console handling for Windows. This works
    by reading/writing to the raw console handle using
    ``{Read,Write}ConsoleW``.

    The problem is that we are going to ``dup2`` over the stdio file
    descriptors when doing ``FDCapture`` and this will ``CloseHandle`` the
    handles used by Python to write to the console. Though there is still some
    weirdness and the console handle seems to only be closed randomly and not
    on the first call to ``CloseHandle``, or maybe it gets reopened with the
    same handle value when we suspend capturing.

    The workaround in this case will reopen stdio with a different fd which
    also means a different handle by replicating the logic in
    "Py_lifecycle.c:initstdio/create_stdio".

    :param stream:
        In practice ``sys.stdout`` or ``sys.stderr``, but given
        here as parameter for unittesting purposes.

    See https://github.com/pytest-dev/py/issues/103.
    r=�pypy_version_infoN�buffer�rawc�����s|ddkrd}nd}tjttj|�����||��|j|j|j|j	��S)Nr�w���)
�io�
TextIOWrapper�open�os�dup�fileno�encoding�errors�newlines�line_buffering)�f�mode�	buffering�buffereds   �r9�
_reopen_stdioz3_windowsconsoleio_workaround.<locals>._reopen_stdiotsn����	�D��G�s�N�N��I�I��I���������
�
�#�#�T�9�5�5�
�J�
�H�
�J�
��
�
�	
r;�rb�wb)r$r>r?�hasattrrFrG�
isinstancerK�_WindowsConsoleIO�stdin�stdout�stderr)rC�
raw_stdoutrYrXs   @r9�_windowsconsoleio_workaroundrcOs����0�<�"�"�7�+�+��w�s�<O�/P�/P�����6�8�$�$�����v�}�e�,�,�H�&.�A���"�"�F�M�J��j�"�"6�7�7����
�
�
�
�
��
�c�i��.�.�C�I���s�z�4�0�0�C�J���s�z�4�0�0�C�J�J�Jr;T��hookwrapper�early_configc#�&K�|j}|jdkrttj��t��|j}t|j��}|�|d��|�	|j
��|���dV�}|���|j
�W|���\}}tj�|��tj�|��dSdS)Nr#�capturemanager)�known_args_namespacer3rcr$r`rB�
pluginmanager�CaptureManager�register�add_cleanup�stop_global_capturing�start_global_capturing�suspend_global_capture�excinfo�read_global_capture�writera)rf�nsrj�capman�outcome�out�errs       r9�pytest_load_initial_conftestsry�s����	�	*�B�	�z�T���$�S�Z�0�0�0����� �.�M�
�B�J�
'�
'�F����6�#3�4�4�4����V�9�:�:�:��!�!�#�#�#��e�e�G�
�!�!�#�#�#���"��-�-�/�/���S��
��������
���������#�"r;c�J�eZdZdZedefd���Zedefd���ZdS)�EncodedFile�r(c�*�t|j��S�N)�reprrF��selfs r9�namezEncodedFile.name�s���D�K� � � r;c�B�|jj�dd��S)N�b�)rFrV�replacer�s r9rVzEncodedFile.mode�s���{��'�'��R�0�0�0r;N)�__name__�
__module__�__qualname__�	__slots__�property�strr�rVr|r;r9r{r{�se�������I�
�!�c�!�!�!��X�!�
�1�c�1�1�1��X�1�1�1r;r{c�,��eZdZd�fd�Zdefd�Z�xZS)�	CaptureIOr(Nc�t��t���tj��ddd���dS)N�UTF-8r�T)rQ�newline�
write_through)�super�__init__rK�BytesIO)r��	__class__s �r9r�zCaptureIO.__init__�s1���
�����������SW��X�X�X�X�Xr;c��t|jtj��sJ�|j����d��S)Nr�)r]rFrKr��getvalue�decoder�s r9r�zCaptureIO.getvalue�s>���$�+�r�z�2�2�2�2�2��{�#�#�%�%�,�,�W�5�5�5r;�r(N)r�r�r�r�r�r��
__classcell__�r�s@r9r�r��s^�������Y�Y�Y�Y�Y�Y�6�#�6�6�6�6�6�6�6�6r;r�c�<��eZdZdeddf�fd�Zdedef�fd�Z�xZS)�TeeCaptureIO�otherr(Nc�V��||_t�����dSr~)�_otherr�r�)r�r�r�s  �r9r�zTeeCaptureIO.__init__�s&������
���������r;�sc�z��t���|��|j�|��Sr~)r�rsr�)r�r�r�s  �r9rszTeeCaptureIO.write�s/���
���
�
�a�����{� � ��#�#�#r;)	r�r�r�rr�r��intrsr�r�s@r9r�r��sw��������f���������$�s�$�s�$�$�$�$�$�$�$�$�$�$r;r�c��eZdZedefd���Zd"dedefd�ZeZdefd�Z	d"de
edeefd�Zde
efd	�Zdefd
�Zd#d�Zdefd
�Zd#d�Zdefd�Zd$dededefd�Zdefd�Zdefd�Zd%de
edefd�Zdedefd�Zdeeddfd�Zdefd�Zd&d�Zde
eede
ede
e ddfd �Z!ede"fd!���Z#dS)'�DontReadFromInputr(c�$�tjjSr~)r$�	__stdin__rQr�s r9rQzDontReadFromInput.encoding�s
���}�%�%r;rJ�sizec� �td����NzJpytest: reading from stdin while output is captured!  Consider using `-s`.��OSError�r�r�s  r9�readzDontReadFromInput.read�����X�
�
�	
r;c�*�|���Sr~)�readliner�s r9�__next__zDontReadFromInput.__next__�s���}�}���r;�hintc� �td���r�r�)r�r�s  r9�	readlineszDontReadFromInput.readlines�r�r;c��|Sr~r|r�s r9�__iter__zDontReadFromInput.__iter__�����r;c� �td���)Nz/redirected stdin is pseudofile, has no fileno()rr�s r9rPzDontReadFromInput.fileno�s��"�#T�U�U�Ur;Nc� �td���)Nz.redirected stdin is pseudofile, has no flush()rr�s r9�flushzDontReadFromInput.flush�s��"�#S�T�T�Tr;c��dS�NFr|r�s r9�isattyzDontReadFromInput.isatty�����ur;c��dSr~r|r�s r9�closezDontReadFromInput.close�����r;c��dSr�r|r�s r9�readablezDontReadFromInput.readable�r�r;r�offset�whencec� �td���)Nz0redirected stdin is pseudofile, has no seek(int)r)r�r�r�s   r9�seekzDontReadFromInput.seek�s��"�#U�V�V�Vr;c��dSr�r|r�s r9�seekablezDontReadFromInput.seekable�r�r;c� �td���)Nz-redirected stdin is pseudofile, has no tell()rr�s r9�tellzDontReadFromInput.tell�s��"�#R�S�S�Sr;c� �td���)Nzcannot truncate stdinrr�s  r9�truncatezDontReadFromInput.truncate����"�#:�;�;�;r;�datac� �td���)Nzcannot write to stdinr�r�r�s  r9rszDontReadFromInput.write�r�r;�linesc� �td���)NzCannot write to stdinr)r�r�s  r9�
writelineszDontReadFromInput.writelines�r�r;c��dSr�r|r�s r9�writablezDontReadFromInput.writable�r�r;c��|Sr~r|r�s r9�	__enter__zDontReadFromInput.__enter__�r�r;�type�value�	tracebackc��dSr~r|)r�r�r�r�s    r9�__exit__zDontReadFromInput.__exit__s	��	
�r;c��|Sr~r|r�s r9rFzDontReadFromInput.buffer
s	���r;)rJr�)rr~)r(r�)$r�r�r�r�r�rQr�r�r�r�rrr�r
r�rPr��boolr�r�r�r�r�r�r�rsrr�r�r�r�
BaseExceptionrr�r	rFr|r;r9r�r��s�������
�&�#�&�&�&��X�&�
�
��
�c�
�
�
�
�
�H��#�����
�
�h�s�m�
�T�#�Y�
�
�
�
�
�(�3�-�����V��V�V�V�V�U�U�U�U�������
�
�
�
��$�����W�W�3�W��W�C�W�W�W�W��$�����T�c�T�T�T�T�<�<�X�c�]�<�c�<�<�<�<�<�#�<�#�<�<�<�<�<���
�<�$�<�<�<�<��$���������
��t�M�*�+�
��
�&�
��M�*�	
�

�
�
�
�
��������X���r;r�c��eZdZUeed<ejdeddfd���Zejd
d���Z	ejd
d���Z
ejd
d���Zejd
d	���Zejd
eddfd���Z
ejdefd���ZdS)�CaptureBase�EMPTY_BUFFERr#r(Nc��t���r~��NotImplementedError�r�r#s  r9r�zCaptureBase.__init__���!�#�#�#r;c��t���r~r�r�s r9�startzCaptureBase.startr�r;c��t���r~r�r�s r9�donezCaptureBase.doner�r;c��t���r~r�r�s r9�suspendzCaptureBase.suspend"r�r;c��t���r~r�r�s r9�resumezCaptureBase.resume&r�r;r�c��t���r~r�r�s  r9�writeorgzCaptureBase.writeorg*r�r;c��t���r~r�r�s r9�snapzCaptureBase.snap.r�r;r�)r�r�r�r�__annotations__�abc�abstractmethodr�r�r�r�r�r�r�r�r|r;r9r�r�s?�������������$�3�$�4�$�$�$���$�	��$�$�$���$�	��$�$�$���$�	��$�$�$���$�	��$�$�$���$�	��$�V�$��$�$�$���$�	��$�f�$�$�$���$�$�$r;r�r_r`ra)r��c�^�eZdZdZdeddfd�Zd
d�Zd
d�Zd
d�Zd
d	�Z	de
fd
�Zde
ddfd�ZdS)�	NoCapturer�r#r(Nc��dSr~r|r�s  r9r�zNoCapture.__init__9r�r;c��dSr~r|r�s r9r�zNoCapture.start<r�r;c��dSr~r|r�s r9r�zNoCapture.done?r�r;c��dSr~r|r�s r9r�zNoCapture.suspendBr�r;c��dSr~r|r�s r9r�zNoCapture.resumeEr�r;c��dS�Nr�r|r�s r9r�zNoCapture.snapHs���rr;r�c��dSr~r|r�s  r9r�zNoCapture.writeorgKr�r;r�)
r�r�r�r�r�r�r�r�r�r�r�r�r�r|r;r9r�r�6s��������L�
�3�
�4�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
��c�����
�S�
�T�
�
�
�
�
�
r;r�c
��eZdZ	ddd�dedeededdfd�Zd	edefd
�Z	defd�Z
ded
eedfddfd�Zdd�Z
dd�Zdd�Zdd�ZdS)�SysCaptureBaseNF��teer#�tmpfiler	r(c���t|}tt|��|_||_|�9|dkrt��}n$|st
��nt|j��}||_d|_	dS)Nr_�initialized)
�patchsysdict�getattrr$�_oldr�r�r�r�r
�_state)r�r#r
r	r�s     r9r�zSysCaptureBase.__init__Pso���B���#�C��.�.��	���	��?��w���+�-�-���-0�M�)�+�+�+�l�4�9�6M�6M�����#����r;�
class_namec��d�||jt|d��rt|j��pd|j|j��S�Nz(<{} {} _old={} _state={!r} tmpfile={!r}>rz<UNSET>)�formatr�r\rrrr
)r�rs  r9rzSysCaptureBase.repr^sK��9�@�@���I��D�&�!�!�5�d�4�9�o�o�B���K��L�
�
�	
r;c��d�|jj|jt	|d��rt|j��pd|j|j��Sr)	rr�r�r�r\rrrr
r�s r9�__repr__zSysCaptureBase.__repr__gsP��9�@�@��N�#��I��D�&�!�!�5�d�4�9�o�o�B���K��L�
�
�	
r;�op�states.c��|j|vs7Jd�||jd�|�������dS�Nz+cannot {} in state {!r}: expected one of {}z, �rr�join�r�rrs   r9�
_assert_statezSysCaptureBase._assert_statep�K���K�6�!�!�!�8�?�?����T�Y�Y�v�.�.�
�
�
"�!�!�!�!r;c��|�dd��tt|j|j��d|_dS)Nr��r�started)r�setattrr$r�r
rr�s r9r�zSysCaptureBase.startws:�����7�$4�5�5�5���T�Y���-�-�-�����r;c���|�dd��|jdkrdStt|j|j��|`|j���d|_dS)Nr��rr"�	suspendedr�)rrr#r$r�rr
r�r�s r9r�zSysCaptureBase.done|se�����6�#R�S�S�S��;�&� � ��F���T�Y��	�*�*�*��I������������r;c��|�dd��tt|j|j��d|_dS�Nr��r"r&r&)rr#r$r�rrr�s r9r�zSysCaptureBase.suspend�s:�����9�&>�?�?�?���T�Y��	�*�*�*�!����r;c��|�dd��|jdkrdStt|j|j��d|_dS�Nr�r)r")rrr#r$r�r
r�s r9r�zSysCaptureBase.resume�sL�����8�%=�>�>�>��;�)�#�#��F���T�Y���-�-�-�����r;r~r�)r�r�r�r�rrr�r�r�rrrrr�r�r�r�r|r;r9rrOs ������37�$�HM�$�$�$��$� (�� 0�$�AE�$�	
�$�$�$�$�
�s�
�s�
�
�
�
�
�#�
�
�
�
�
��
�U�3��8�_�
��
�
�
�
� � � � �
����"�"�"�"�
 � � � � � r;rc�.�eZdZdZdefd�Zdeddfd�ZdS)�SysCaptureBinaryr;r(c��|�dd��|j�d��|jj���}|j�d��|j���|S�Nr�r)r�rr
r�rFr�r��r��ress  r9r�zSysCaptureBinary.snap��t�����6�#;�<�<�<�����!�����l�!�&�&�(�(������!������������
r;r�Nc���|�dd��|j���|jj�|��|jj���dS�Nr�r))rrr�rFrsr�s  r9r�zSysCaptureBinary.writeorg�sa�����:�'?�@�@�@��	�������	����t�$�$�$��	���� � � � � r;)r�r�r�r��bytesr�r�r|r;r9r-r-�sV�������L��e�����!�U�!�t�!�!�!�!�!�!r;r-c�.�eZdZdZdefd�Zdeddfd�ZdS)�
SysCapturer�r(c��|�dd��t|jt��sJ�|j���}|j�d��|j���|Sr/)rr]r
r�r�r�r�r1s  r9r�zSysCapture.snap�ss�����6�#;�<�<�<��$�,�	�2�2�2�2�2��l�#�#�%�%������!������������
r;r�Nc��|�dd��|j�|��|j���dSr5)rrrsr�r�s  r9r�zSysCapture.writeorg�sE�����:�'?�@�@�@��	��������	�������r;)r�r�r�r�r�r�r�r|r;r9r8r8�sV�������L��c������S��T������r;r8c�n�eZdZdeddfd�Zdefd�Zdedeedfddfd	�Zdd
�Z	dd�Z
dd�Zdd
�ZdS)�
FDCaptureBase�targetfdr(Nc�r�||_	tj|��d|_nX#t$rKtjtjtj��|_tj|j|��YnwxYwtj	|��|_
|dkr5ttjd���|_t|��|_
n_ttd���dddd���|_|t vrt||j��|_
nt#|��|_
d	|_dS)
Nr�utf-8)rQ)rWr�r�T)rQrRr�r�r)r=rN�fstat�targetfd_invalidr�rM�devnull�O_RDWR�dup2rO�
targetfd_saver
r8�
syscapturer{rr
r�r)r�r=s  r9r�zFDCaptureBase.__init__�s-�� ��
�	)��H�X���� %)�D�!�!���
	5�
	5�
	5�46�7�2�:�r�y�3Q�3Q�D�!��G�D�)�8�4�4�4�4�4�
	5����  �V�H�-�-����q�=�=���
�W�=�=�=�D�L�0:�8�0D�0D�D�O�O�&���*�*�*� � ��"����D�L��<�'�'�",�X�t�|�"D�"D����"+�H�"5�"5���#����s�%�AA:�9A:c�p�d�|jj|j|j|j|j��S)Nz)<{} {} oldfd={} _state={!r} tmpfile={!r}>)rr�r�r=rErr
r�s r9rzFDCaptureBase.__repr__�s7��:�A�A��N�#��M����K��L�
�
�	
r;rr.c��|j|vs7Jd�||jd�|�������dSrrrs   r9rzFDCaptureBase._assert_state�rr;c���|�dd��tj|j���|j��|j���d|_dS)z4Start capturing on targetfd using memorized tmpfile.r�r!r"N)	rrNrDr
rPr=rFr�rr�s r9r�zFDCaptureBase.start�sZ�����7�$4�5�5�5�
����#�#�%�%�t�}�5�5�5������������r;c��|�dd��|jdkrdStj|j|j��tj|j��|j�B|j|jkrtj|j��tj|j��|j�	��|j
���d|_dS)z_Stop capturing, restore streams, return original capture file,
        seeked to position zero.r�r%N)rrrNrDrEr=r�rArFr�r
r�s r9r�zFDCaptureBase.done�s���	
���6�#R�S�S�S��;�&� � ��F�
���"�D�M�2�2�2�
���#�$�$�$�� �,��$��
�5�5�����'�'�'��H�T�*�+�+�+�������������������r;c���|�dd��|jdkrdS|j���t	j|j|j��d|_dSr()rrrFr�rNrDrEr=r�s r9r�zFDCaptureBase.suspendsa�����9�&>�?�?�?��;�+�%�%��F�����!�!�!�
���"�D�M�2�2�2�!����r;c���|�dd��|jdkrdS|j���t	j|j���|j��d|_dSr+)	rrrFr�rNrDr
rPr=r�s r9r�zFDCaptureBase.resumesl�����8�%=�>�>�>��;�)�#�#��F����� � � �
����#�#�%�%�t�}�5�5�5�����r;r�)
r�r�r�r�r�r�rrrr�r�r�r�r|r;r9r<r<�s�������'$��'$��'$�'$�'$�'$�R
�#�
�
�
�
�
��
�U�3��8�_�
��
�
�
�
� � � � ����� "�"�"�"� � � � � � r;r<c�2�eZdZdZdZdefd�Zdeddfd�ZdS)�FDCaptureBinaryzWCapture IO to/from a given OS-level file descriptor.

    snap() produces `bytes`.
    r;r(c��|�dd��|j�d��|jj���}|j�d��|j���|Sr/r0r1s  r9r�zFDCaptureBinary.snapr3r;r�Nc�f�|�dd��tj|j|��dS)�"Write to original file descriptor.r�r)N)rrNrsrEr�s  r9r�zFDCaptureBinary.writeorg's4�����:�'?�@�@�@�
���#�T�*�*�*�*�*r;)r�r�r��__doc__r�r6r�r�r|r;r9rNrNsb��������
�L��e�����+�U�+�t�+�+�+�+�+�+r;rNc�2�eZdZdZdZdefd�Zdeddfd�ZdS)�	FDCapturezTCapture IO to/from a given OS-level file descriptor.

    snap() produces text.
    r�r(c��|�dd��|j�d��|j���}|j�d��|j���|Sr/)rr
r�r�r�r1s  r9r�zFDCapture.snap5sq�����6�#;�<�<�<�����!�����l���!�!������!������������
r;r�Nc��|�dd��tj|j|�d����dS)rQr�r)r?N)rrNrsrE�encoder�s  r9r�zFDCapture.writeorg=s@�����:�'?�@�@�@�
���#�T�[�[��%9�%9�:�:�:�:�:r;)r�r�r�rRr�r�r�r�r|r;r9rTrT-sb��������
�L��c�����;�S�;�T�;�;�;�;�;�;r;rT)��c�(�eZdZUdZeed<eed<dS)�
CaptureResult�2The result of :method:`CaptureFixture.readouterr`.rwrxN)r�r�r�rRrr�r|r;r9r[r[Js(�������@�@�
����
�����r;r[c��eZdZdZdZdS)r[r\r|N)r�r�r�rRr�r|r;r9r[r[Ss������	A�@��	�	�	r;rwrxc���eZdZdZdZdeeedeeedeeeddfd�Zde	fd�Z
dd	�Zdeeeffd
�Z
ddeddfd�Zdd�Zdd
�Zdefd�Zdeefd�ZdS)�MultiCaptureNF�in_rwrxr(c�0�||_||_||_dSr~�r`rwrx)r�r`rwrxs    r9r�zMultiCapture.__init___s��36���25���25����r;c�f�d�|j|j|j|j|j��S)NzH<MultiCapture out={!r} err={!r} in_={!r} _state={!r} _in_suspended={!r}>)rrwrxr`r�
_in_suspendedr�s r9rzMultiCapture.__repr__is4��Y�`�`��H��H��H��K���
�
�	
r;c���d|_|jr|j���|jr|j���|jr|j���dSdS)Nr")rr`r�rwrxr�s r9�start_capturingzMultiCapture.start_capturingrsm������8�	��H�N�N�����8�	��H�N�N�����8�	��H�N�N������	�	r;c���|���\}}|r#|j�J�|j�|��|r#|j�J�|j�|��||fS)z?Pop current snapshot out/err capture and flush to orig streams.)�
readouterrrwr�rx�r�rwrxs   r9�pop_outerr_to_origzMultiCapture.pop_outerr_to_orig{sv���?�?�$�$���S��	#��8�'�'�'��H���c�"�"�"��	#��8�'�'�'��H���c�"�"�"��C�x�r;c���d|_|jr|j���|jr|j���|r)|jr$|j���d|_dSdSdS)Nr&T)rrwr�rxr`rd�r�r`s  r9�suspend_capturingzMultiCapture.suspend_capturing�s���!����8�	��H�������8�	��H�������	&�4�8�	&��H������!%�D����	&�	&�	&�	&r;c��d|_|jr|j���|jr|j���|jr+|j�J�|j���d|_dSdS)Nr"F)rrwr�rxrdr`r�s r9�resume_capturingzMultiCapture.resume_capturing�s�������8�	��H�O�O�����8�	��H�O�O������	'��8�'�'�'��H�O�O����!&�D����	'�	'r;c��|jdkrtd���d|_|jr|j���|jr|j���|jr|j���dSdS)z+Stop capturing and reset capturing streams.�stoppedzwas already stoppedN)r�
ValueErrorrwr�rxr`r�s r9�stop_capturingzMultiCapture.stop_capturing�s~���;�)�#�#��2�3�3�3�����8�	��H�M�M�O�O�O��8�	��H�M�M�O�O�O��8�	��H�M�M�O�O�O�O�O�	�	r;c��|jdkS)z7Whether actively capturing -- not suspended or stopped.r")rr�s r9�
is_startedzMultiCapture.is_started�s���{�i�'�'r;c��|jr|j���nd}|jr|j���nd}t||��Sr)rwr�rxr[ris   r9rhzMultiCapture.readouterr�sF��!%��1�d�h�m�m�o�o�o�r��!%��1�d�h�m�m�o�o�o�r���S�#�&�&�&r;r��F)r�r�r�rrdrr�rr�r�rrfrrjr�rmrorsrur[rhr|r;r9r_r_[sS������
�F��M�6�
�k�&�)�
*�6��k�&�)�
*�6��k�&�)�
*�	6�

�6�6�6�6�
�#�
�
�
�
�����	�E�&�&�.�$9�	�	�	�	�&�&�T�&�d�&�&�&�&�	'�	'�	'�	'�
�
�
�
�(�D�(�(�(�(�'�M�&�1�'�'�'�'�'�'r;r_r,�_CaptureMethodc��|dkr9ttd��td��td�����S|dkr9ttd��td��td�����S|dkrtddd���S|dkr0tdtdd	�
��tdd	�
�����Std|�����)Nr#rr�r�rbr$r%r&Trzunknown capturing method: )r_rTr8rr)r,s r9�_get_multicapturerz�s���
��~�~��	�!���)�A�,�,�I�a�L�L�Q�Q�Q�Q�	�5����
�1�
�
�:�a�=�=�j�QR�m�m�T�T�T�T�	�4�����$�D�9�9�9�9�	�9�	�	���*�Q�D�1�1�1�z�!��7N�7N�7N�
�
�
�	
��<�&�<�<�
=�
=�=r;c��eZdZdZd*d�Zdefd�Zdeeeffd�Z	defd	�Z
d+d
�Zd+d�Zd+d�Z
d,deddfd�Zd,deddfd�Zd+d�Zdeefd�Zd-d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zejdedfd���Zejdedededfd���Zed �!��d"e fd#���Z!ed �!��dededfd$���Z"ed �!��dededfd%���Z#ed �!��dededfd&���Z$ed �'��d+d(���Z%ed �'��d+d)���Z&dS).rka�The capture plugin.

    Manages that the appropriate capture method is enabled/disabled during
    collection and each test phase (setup, call, teardown). After each of
    those points, the captured output is obtained and attached to the
    collection/runtest report.

    There are two levels of capture:

    * global: enabled by default and can be suppressed by the ``-s``
      option. This is always enabled/disabled during collection and each test
      phase.

    * fixture: when a test function or one of its fixture depend on the
      ``capsys`` or ``capfd`` fixtures. In this case special handling is
      needed to ensure the fixtures take precedence over the global capture.
    r,rxr(Nc�0�||_d|_d|_dSr~)�_method�_global_capturing�_capture_fixture)r�r,s  r9r�zCaptureManager.__init__�s��$���>B���?C����r;c�N�d�|j|j|j��S)NzJ<CaptureManager _method={!r} _global_capturing={!r} _capture_fixture={!r}>)rr}r~rr�s r9rzCaptureManager.__repr__�s)��[�b�b��L�$�0�$�2G�
�
�	
r;c�h�|���rdS|jrd|jjjzSdS)N�globalz
fixture %sF)�is_globally_capturingr�request�fixturenamer�s r9�is_capturingzCaptureManager.is_capturing�s@���%�%�'�'�	��8�� �	L��$�"7�"?�"K�K�K��ur;c��|jdkS)Nr%)r}r�s r9r�z$CaptureManager.is_globally_capturing�s���|�t�#�#r;c�|�|j�J�t|j��|_|j���dSr~)r~rzr}rfr�s r9roz%CaptureManager.start_global_capturing�s>���%�-�-�-�!2�4�<�!@�!@�����.�.�0�0�0�0�0r;c��|j�;|j���|j���d|_dSdSr~)r~rjrsr�s r9rnz$CaptureManager.stop_global_capturing�sK���!�-��"�5�5�7�7�7��"�1�1�3�3�3�%)�D�"�"�"�.�-r;c�J�|j�|j���dSdSr~)r~ror�s r9�resume_global_capturez$CaptureManager.resume_global_capture�s0���!�-��"�3�3�5�5�5�5�5�.�-r;Fr`c�N�|j�|j�|���dSdS)N�r`)r~rmrls  r9rpz%CaptureManager.suspend_global_capture�s3���!�-��"�4�4��4�=�=�=�=�=�.�-r;c�X�|���|�|��dSr~)�suspend_fixturerprls  r9r�zCaptureManager.suspends.���������#�#�C�(�(�(�(�(r;c�V�|���|���dSr~)r��resume_fixturer�s r9r�zCaptureManager.resumes,���"�"�$�$�$��������r;c�F�|j�J�|j���Sr~)r~rhr�s r9rrz"CaptureManager.read_global_capture
s&���%�1�1�1��%�0�0�2�2�2r;�capture_fixture�CaptureFixture[Any]c��|jrK|jjj}|jj}|j�d�||����||_dS)Nz%cannot use {} and {} at the same time)rr�r��
raiseerrorr)r�r��current_fixture�requested_fixtures    r9�set_fixturezCaptureManager.set_fixturesj��� �	�"�3�;�G�O� /� 7� C���#�.�.�7�>�>�%����
�
�
�
!0����r;c��d|_dSr~)rr�s r9�
unset_fixturezCaptureManager.unset_fixtures�� $����r;c�J�|jr|j���dSdS)z|If the current item is using ``capsys`` or ``capfd``, activate
        them so they take precedence over the global capture.N)r�_startr�s r9�activate_fixturezCaptureManager.activate_fixtures4��� �	+��!�(�(�*�*�*�*�*�	+�	+r;c�J�|jr|j���dSdS)zDDeactivate the ``capsys`` or ``capfd`` fixture of this item, if any.N)rr�r�s r9�deactivate_fixturez!CaptureManager.deactivate_fixture$s2��� �	*��!�'�'�)�)�)�)�)�	*�	*r;c�J�|jr|j���dSdSr~)r�_suspendr�s r9r�zCaptureManager.suspend_fixture)s2��� �	-��!�*�*�,�,�,�,�,�	-�	-r;c�J�|jr|j���dSdSr~)r�_resumer�s r9r�zCaptureManager.resume_fixture-s2��� �	,��!�)�)�+�+�+�+�+�	,�	,r;�NNNc#�K�|jo|j���}|r|���|jo|j���}|r|���	dV�|r|���|r|���dSdS#|r|���|r|���wwxYw)zLContext manager to temporarily disable global and current fixture capturing.N)r�_is_startedr�r~rurpr�r�)r��
do_fixture�	do_globals   r9�global_and_fixture_disabledz*CaptureManager.global_and_fixture_disabled3s�����*�R�t�/D�/P�/P�/R�/R�
��	#�� � �"�"�"��*�R�t�/E�/P�/P�/R�/R�	��	*��'�'�)�)�)�	&��E�E�E��
-��*�*�,�,�,��
&��#�#�%�%�%�%�%�
&�
&���
-��*�*�,�,�,��
&��#�#�%�%�%�%�
&���s�0B$�$/C�when�itemc#�K�|���|���	dV�|���|�d���n/#|���|�d���wxYw|���\}}|�|d|��|�|d|��dS)NFr�r`ra)r�r�r�rprr�add_report_section)r�r�r�rwrxs     r9�item_capturezCaptureManager.item_captureDs������"�"�$�$�$�������	3��E�E�E��#�#�%�%�%��'�'�E�'�2�2�2�2��
�#�#�%�%�%��'�'�E�'�2�2�2�2�����+�+�-�-���S�����h��4�4�4�����h��4�4�4�4�4s�A�,BTrd�	collectorc#�jK�t|t��r�|���dV�}|���|���\}}|���}|r|j�d|f��|r|j�d|f��dSdSdV�dS)NzCaptured stdoutzCaptured stderr)r]rr�rprr�
get_result�sections�append)r�r�rvrwrx�reps      r9�pytest_make_collect_reportz)CaptureManager.pytest_make_collect_reportTs������i��&�&�	��&�&�(�(�(��e�e�G��'�'�)�)�)��/�/�1�1�H�C���$�$�&�&�C��
>���#�#�%6��$<�=�=�=��
>���#�#�%6��$<�=�=�=�=�=�
>�
>�
�E�E�E�E�Er;c#�pK�|�d|��5dV�ddd��dS#1swxYwYdS)N�setup�r��r�r�s  r9�pytest_runtest_setupz#CaptureManager.pytest_runtest_setupcs�����
�
�
�w��
-�
-�	�	��E�E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��+�/�/c#�pK�|�d|��5dV�ddd��dS#1swxYwYdS)N�callr�r�s  r9�pytest_runtest_callz"CaptureManager.pytest_runtest_callhs�����
�
�
�v�t�
,�
,�	�	��E�E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r�c#�pK�|�d|��5dV�ddd��dS#1swxYwYdS)N�teardownr�r�s  r9�pytest_runtest_teardownz&CaptureManager.pytest_runtest_teardownms�����
�
�
�z�4�
0�
0�	�	��E�E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r�)�tryfirstc�.�|���dSr~�rnr�s r9�pytest_keyboard_interruptz(CaptureManager.pytest_keyboard_interruptr����"�"�$�$�$�$�$r;c�.�|���dSr~r�r�s r9�pytest_internalerrorz#CaptureManager.pytest_internalerrorvr�r;)r,rxr(Nr�rw)r�r�r(N)'r�r�r�rRr�r�rrr�r�r�rornr�rpr�r�r[rrr�r�r�r�r�r��
contextlib�contextmanagerr
r�rr�rrr�r�r�r�r�r�r|r;r9rkrk�s���������$D�D�D�D�

�#�
�
�
�
�
�e�C��I�.�����$�t�$�$�$�$�1�1�1�1�
*�*�*�*�6�6�6�6�>�>�$�>�4�>�>�>�>�)�)�4�)�D�)�)�)�)�
����3�]�3�%7�3�3�3�3�	0�	0�	0�	0�%�%�%�%�+�+�+�+�*�*�*�*�
-�-�-�-�,�,�,�,���&�Y�7G�-H�&�&�&���&� ��5��5�D�5�Y�?O�5P�5�5�5���5��X�$�����I���� ����X�$�������)�<L�2M���� ����X�$��������;K�1L���� ����X�$�����D��Y�?O�5P���� ����X�t����%�%�%���%��X�t����%�%�%���%�%�%r;rkc	��eZdZdZdd�deeedededdfd	�Z	dd
�Z
dd�Zdeefd�Z
dd
�Zdd�Zdefd�Zejdedfd���ZdS)�CaptureFixturez|Object returned by the :fixture:`capsys`, :fixture:`capsysbinary`,
    :fixture:`capfd` and :fixture:`capfdbinary` fixtures.F��	_ispytest�captureclassr�r�r(Nc��t|��||_||_d|_|jj|_|jj|_dSr~)rr�r��_capturer��
_captured_out�
_captured_err)r�r�r�r�s    r9r�zCaptureFixture.__init__sJ��	�y�!�!�!�7C������8<��
�%)�%6�%C���%)�%6�%C����r;c���|j�Xtd|�d��|�d�����|_|j���dSdS)Nr�r�rb)r�r_r�rfr�s r9r�zCaptureFixture._start�si���=� �(���%�%�a�(�(��%�%�a�(�(����D�M�

�M�)�)�+�+�+�+�+�
!� r;c���|j�^|j���\}}|xj|z
c_|xj|z
c_|j���d|_dSdSr~)r�rjr�r�rsris   r9r�zCaptureFixture.close�sp���=�$��}�7�7�9�9�H�C�����#�%������#�%����M�(�(�*�*�*� �D�M�M�M�%�$r;c���|j|j}}|j�&|j���\}}||z
}||z
}|jj|_|jj|_t
||��S)z�Read and return the captured output so far, resetting the internal
        buffer.

        :returns:
            The captured content as a namedtuple with ``out`` and ``err``
            string attributes.
        )r�r�r�rhr�r�r[)r��captured_out�captured_errrwrxs     r9rhzCaptureFixture.readouterr�sr��&*�%7��9K�l���=�$��}�/�/�1�1�H�C���C��L��C��L�!�.�;���!�.�;����\�<�8�8�8r;c�J�|j�|j���dSdS)z1Suspend this fixture's own capturing temporarily.N)r�rmr�s r9r�zCaptureFixture._suspend�s,���=�$��M�+�+�-�-�-�-�-�%�$r;c�J�|j�|j���dSdS)z0Resume this fixture's own capturing temporarily.N)r�ror�s r9r�zCaptureFixture._resume�s,���=�$��M�*�*�,�,�,�,�,�%�$r;c�F�|j�|j���SdS)z5Whether actively capturing -- not disabled or closed.NF)r�rur�s r9r�zCaptureFixture._is_started�s#���=�$��=�+�+�-�-�-��ur;r�c#�K�|jjj�d��}|���5dV�ddd��dS#1swxYwYdS)z>Temporarily disable capturing while inside the ``with`` block.rhN)r��configrj�	getpluginr�)r��
capmanagers  r9�disabledzCaptureFixture.disabled�s�����&*�\�%8�%F�%P�%P��&
�&
�
��
3�
3�
5�
5�	�	��E�E�E�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A
�
A�Ar�)r�r�r�rRrr�rrr�r�r�r�r[rhr�r�r�r�r�r
r�r|r;r9r�r�{s7������=�=� �D�D�D��;�v�.�/�D��D�
�D�
�
D�D�D�D�,�,�,�,�!�!�!�!�9�M�&�1�9�9�9�9�".�.�.�.�
-�-�-�-�
�T��������)�$4�5��������r;r�r�c#� K�|jj�d��}tt|d���}|�|��|���|V�|���|���dS)aEnable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.

    The captured output is made available via ``capsys.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``text`` objects.

    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.

    Example:

    .. code-block:: python

        def test_output(capsys):
            print("hello")
            captured = capsys.readouterr()
            assert captured.out == "hello\n"
    rhTr�N)	r�rjr�r�r8r�r�r�r��r�rur�s   r9�capsysr��s�����&%�^�9�C�C�DT�U�U�F�$�Z��D�I�I�I�O�
����'�'�'�������
����������
�������r;c#� K�|jj�d��}tt|d���}|�|��|���|V�|���|���dS)a'Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.

    The captured output is made available via ``capsysbinary.readouterr()``
    method calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``bytes`` objects.

    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.

    Example:

    .. code-block:: python

        def test_output(capsysbinary):
            print("hello")
            captured = capsysbinary.readouterr()
            assert captured.out == b"hello\n"
    rhTr�N)	r�rjr�r�r-r�r�r�r�r�s   r9�capsysbinaryr��s�����&%�^�9�C�C�DT�U�U�F�$�%5�w�$�O�O�O�O�
����'�'�'�������
����������
�������r;c#� K�|jj�d��}tt|d���}|�|��|���|V�|���|���dS)aEnable text capturing of writes to file descriptors ``1`` and ``2``.

    The captured output is made available via ``capfd.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``text`` objects.

    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.

    Example:

    .. code-block:: python

        def test_system_echo(capfd):
            os.system('echo "hello"')
            captured = capfd.readouterr()
            assert captured.out == "hello\n"
    rhTr�N)	r�rjr�r�rTr�r�r�r�r�s   r9�capfdr�s�����&%�^�9�C�C�DT�U�U�F�$�Y��4�H�H�H�O�
����'�'�'�������
����������
�������r;c#� K�|jj�d��}tt|d���}|�|��|���|V�|���|���dS)a-Enable bytes capturing of writes to file descriptors ``1`` and ``2``.

    The captured output is made available via ``capfd.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``byte`` objects.

    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.

    Example:

    .. code-block:: python

        def test_system_echo(capfdbinary):
            os.system('echo "hello"')
            captured = capfdbinary.readouterr()
            assert captured.out == b"hello\n"

    rhTr�N)	r�rjr�r�rNr�r�r�r�r�s   r9�capfdbinaryr� s�����(%�^�9�C�C�DT�U�U�F�$�_�g��N�N�N�O�
����'�'�'�������
����������
�������r;r�)PrRr��collectionsr�rKrNr$r�tempfiler�typesr�typingrrr	r
rrr
rrrrrrrr�_pytest.compatr�_pytest.configrr�_pytest.config.argparsingr�_pytest.deprecatedr�_pytest.fixturesrr�
_pytest.nodesrrr�typing_extensionsr r!rxr:rBrcryrLr{r�r�r��ABCr�r
r�r�rr6r-r8r<rNrT�version_infor[�
namedtupler_rzrkr�r�r�r�r�r|r;r9�<module>r�s���1�1�
�
�
�
���������	�	�	�	�	�	�	�	�
�
�
�
�#�#�#�#�#�#�"�"�"�"�"�"������������������������������������������������������������������������������������� � � � � � ������� � � � � � �!�!�!�!�!�!�#�#�#�#�#�#�,�,�,�,�,�,�-�-�-�-�-�-�$�$�$�$�$�$�'�'�'�'�'�'�#�#�#�#�#�#��������������;�'�'�'�'�'�'�)�)�)�)�)�)��9�:�N��V�������&����51��51�D�51�51�51�51�p
��d������������2
1�
1�
1�
1�
1�"�"�
1�
1�
1� 6�6�6�6�6�� �6�6�6�$�$�$�$�$�9�$�$�$�I�I�I�I�I��I�I�I�^$�$�$�$�$�#�'�7�6�?�$�$�$�@�x�H�5�5��
�
�
�
�
��C� �
�
�
�2@ �@ �@ �@ �@ �[��(�@ �@ �@ �F!�!�!�!�!�~�e�,�!�!�!�$�������$����"_ �_ �_ �_ �_ �K��'�_ �_ �_ �D+�+�+�+�+�m�E�*�+�+�+�,;�;�;�;�;�
�c�"�;�;�;�6��w���-��
������
�G�F�O����U���������������?�?�������T'�T'�T'�T'�T'�7�6�?�T'�T'�T'�n>�.�>�<��3D�>�>�>�>�"u%�u%�u%�u%�u%�u%�u%�u%�pK�K�K�K�K�W�V�_�K�K�K�b	��J��9�^�C�-@�$��-L�#M����	���6	��*���>�%�3H�$�PT�3T�)U����	���6	��:��)�N�3�,?��t�,K�"L����	���6	����	�.��2G��t�2S�(T����	����r;