HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/_pytest/__pycache__/capture.cpython-310.pyc
o

%we���@sdZddlZddlZddlZddlZddlZddlZddlmZddlm	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+er�ddl,m-Z-dd l,m.Z.e.d!Z/d"e"d#dfd$d%�Z0ded&d'�Z1d(ed#dfd)d*�Z2e d+d,�d-efd.d/��Z3Gd0d1�d1ej4�Z5Gd2d3�d3ej4�Z6Gd4d5�d5e6�Z7Gd6d7�d7e�Z8Gd8d9�d9ej9ee�Z:d:d;d<d=�Z;Gd>d?�d?e:e<�Z=Gd@dA�dAe:e�Z>GdBdC�dCe>e?�Z@GdDdE�dEe>e<�ZAGdFdG�dGe:e�ZBGdHdI�dIeBe?�ZCGdJdK�dKeBe<�ZDejEdLk�sze�r�eGdMdN�dNeee��ZFnGdOdN�dNe�GdNdPdQg�ee�ZFGdRdS�dSee�ZHdTdUd#eHe<fdVdW�ZIGdXdY�dY�ZJGdZd[�d[ee�ZKe&d\e'd#eeKe<ddffd]d^��ZLe&d\e'd#eeKe?ddffd_d`��ZMe&d\e'd#eeKe<ddffdadb��ZNe&d\e'd#eeKe?ddffdcdd��ZOdS)fz+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�returncCs<|�d�}|jddddgd�dd�|jd	d
ddd
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�destr/)�getgroup�
_addoption)r&�group�r7�H/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/capture.py�pytest_addoption-s 
�
�r9cCs4tj�d�rzddl}WdStyYdSwdS)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=r7r7r8�_colorama_workaround@s��r?�streamcs�tj�d�rttd�r
dSt|d�sdSt|jd���r |jjn|j}t|tj�s+dS�fdd�}|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�rawcsF�s|ddkrd}nd}t�tt�|���||�|j|j|j|j	�S)Nr�w���)
�io�
TextIOWrapper�open�os�dup�fileno�encoding�errors�newlines�line_buffering)�f�mode�	buffering��bufferedr7r8�
_reopen_stdiots�z3_windowsconsoleio_workaround.<locals>._reopen_stdio�rb�wb)r#r;r<�hasattrrBrC�
isinstancerF�_WindowsConsoleIO�stdin�stdout�stderr)r@�
raw_stdoutrUr7rSr8�_windowsconsoleio_workaroundOs
r_T��hookwrapper�early_configccs��|j}|jdkrttj�t�|j}t|j�}|�|d�|�	|j
�|��dV}|��|j
durI|��\}}tj�|�tj�|�dSdS)Nr"�capturemanager)�known_args_namespacer1r_r#r\r?�
pluginmanager�CaptureManager�register�add_cleanup�stop_global_capturing�start_global_capturing�suspend_global_capture�excinfo�read_global_capture�writer])rb�nsre�capman�outcome�out�errr7r7r8�pytest_load_initial_conftests�s"�



�rtc@s4eZdZdZedefdd��Zedefdd��ZdS)�EncodedFiler7r'cCs
t|j�S�N)�reprrB��selfr7r7r8�name�s
zEncodedFile.namecCs|jj�dd�S)N�b�)rBrQ�replacerxr7r7r8rQ�szEncodedFile.modeN)�__name__�
__module__�__qualname__�	__slots__�property�strrzrQr7r7r7r8ru�srucs,eZdZd�fdd�Zdefdd�Z�ZS)�	CaptureIOr'Ncst�jt��dddd�dS)N�UTF-8r|T)rL�newline�
write_through)�super�__init__rF�BytesIOrx��	__class__r7r8r��szCaptureIO.__init__cCs"t|jtj�s	J�|j���d�S)Nr�)rYrBrFr��getvalue�decoderxr7r7r8r��szCaptureIO.getvalue�r'N)r~rr�r�r�r��
__classcell__r7r7r�r8r��sr�cs<eZdZdeddf�fdd�Zdedef�fdd�Z�ZS)	�TeeCaptureIO�otherr'Ncs||_t���dSrv)�_otherr�r�)ryr�r�r7r8r��szTeeCaptureIO.__init__�scst��|�|j�|�Srv)r�rnr�)ryr�r�r7r8rn�szTeeCaptureIO.write)	r~rr�rr�r��intrnr�r7r7r�r8r��sr�c@sxeZdZedefdd��Zd6dedefdd�ZeZdefdd	�Z	d6d
e
edeefdd�Zde
efd
d�Zdefdd�Zd7dd�Zdefdd�Zd7dd�Zdefdd�Zd8dededefdd�Zdefdd �Zdefd!d"�Zd9de
edefd#d$�Zd%edefd&d'�Zd(eeddfd)d*�Zdefd+d,�Zd:d-d.�Zd/e
eed0e
ed1e
e ddfd2d3�Z!ede"fd4d5��Z#dS);�DontReadFromInputr'cCstjjSrv)r#�	__stdin__rLrxr7r7r8rL�szDontReadFromInput.encodingrE�sizecC�td���NzJpytest: reading from stdin while output is captured!  Consider using `-s`.��OSError�ryr�r7r7r8�read���zDontReadFromInput.readcCs|��Srv)�readlinerxr7r7r8�__next__��zDontReadFromInput.__next__�hintcCr�r�r�)ryr�r7r7r8�	readlines�r�zDontReadFromInput.readlinescC�|Srvr7rxr7r7r8�__iter__��zDontReadFromInput.__iter__cCr�)Nz/redirected stdin is pseudofile, has no fileno()rrxr7r7r8rK�r�zDontReadFromInput.filenoNcCr�)Nz.redirected stdin is pseudofile, has no flush()rrxr7r7r8�flush�r�zDontReadFromInput.flushcC�dS�NFr7rxr7r7r8�isatty�r�zDontReadFromInput.isattycC�dSrvr7rxr7r7r8�close�r�zDontReadFromInput.closecCr�r�r7rxr7r7r8�readable�r�zDontReadFromInput.readabler�offset�whencecCr�)Nz0redirected stdin is pseudofile, has no seek(int)r)ryr�r�r7r7r8�seek�r�zDontReadFromInput.seekcCr�r�r7rxr7r7r8�seekable�r�zDontReadFromInput.seekablecCr�)Nz-redirected stdin is pseudofile, has no tell()rrxr7r7r8�tell�r�zDontReadFromInput.tellcCr�)Nzcannot truncate stdinrr�r7r7r8�truncate�r�zDontReadFromInput.truncate�datacCr�)Nzcannot write to stdinr�ryr�r7r7r8rn�r�zDontReadFromInput.write�linescCr�)NzCannot write to stdinr)ryr�r7r7r8�
writelines�r�zDontReadFromInput.writelinescCr�r�r7rxr7r7r8�writable�r�zDontReadFromInput.writablecCr�rvr7rxr7r7r8�	__enter__�r�zDontReadFromInput.__enter__�type�value�	tracebackcCr�rvr7)ryr�r�r�r7r7r8�__exit__szDontReadFromInput.__exit__cCr�rvr7rxr7r7r8rB
szDontReadFromInput.buffer)rEr�)rrv)r'r�)$r~rr�r�r�rLr�r�r�r�rr
r�rr�rKr��boolr�r�r�r�r�r�r�rnrr�r�r�r�
BaseExceptionrr�rrBr7r7r7r8r��s@



���
�r�c@s�eZdZUeed<ejdeddfdd��Zejddd��Z	ejdd	d
��Z
ejddd��Zejdd
d��Zejdeddfdd��Z
ejdefdd��ZdS)�CaptureBase�EMPTY_BUFFERr"r'NcC�t��rv��NotImplementedError�ryr"r7r7r8r��zCaptureBase.__init__cCr�rvr�rxr7r7r8�startr�zCaptureBase.startcCr�rvr�rxr7r7r8�doner�zCaptureBase.donecCr�rvr�rxr7r7r8�suspend"r�zCaptureBase.suspendcCr�rvr�rxr7r7r8�resume&r�zCaptureBase.resumer�cCr�rvr�r�r7r7r8�writeorg*r�zCaptureBase.writeorgcCr�rvr�rxr7r7r8�snap.r�zCaptureBase.snapr�)r~rr�r�__annotations__�abc�abstractmethodr�r�r�r�r�r�r�r�r7r7r7r8r�s 
r�r[r\r])r��c@sjeZdZdZdeddfdd�Zddd�Zdd	d
�Zddd�Zdd
d�Z	de
fdd�Zde
ddfdd�ZdS)�	NoCapturer|r"r'NcCr�rvr7r�r7r7r8r�9r�zNoCapture.__init__cCr�rvr7rxr7r7r8r�<r�zNoCapture.startcCr�rvr7rxr7r7r8r�?r�zNoCapture.donecCr�rvr7rxr7r7r8r�Br�zNoCapture.suspendcCr�rvr7rxr7r7r8r�Er�zNoCapture.resumecCr��Nr|r7rxr7r7r8r�Hr�zNoCapture.snapr�cCr�rvr7r�r7r7r8r�Kr�zNoCapture.writeorgr�)
r~rr�r�r�r�r�r�r�r�r�r�r�r7r7r7r8r�6s



r�c
@s�eZdZ	ddd�dedeededdfdd	�Zd
edefdd�Z	defd
d�Z
dedeedfddfdd�Zddd�Z
ddd�Zddd�Zddd�ZdS)�SysCaptureBaseNF��teer"�tmpfiler�r'cCsVt|}tt|�|_||_|dur#|dkrt�}n
|st�nt|j�}||_d|_	dS)Nr[�initialized)
�patchsysdict�getattrr#�_oldrzr�r�r�r��_state)ryr"r�r�rzr7r7r8r�Ps
zSysCaptureBase.__init__�
class_namecCs,d�||jt|d�rt|j�pd|j|j�S�Nz(<{} {} _old={} _state={!r} tmpfile={!r}>r�z<UNSET>)�formatrzrXrwr�r�r�)ryr�r7r7r8rw^s�zSysCaptureBase.reprcCs0d�|jj|jt|d�rt|j�pd|j|j�Sr�)	r�r�r~rzrXrwr�r�r�rxr7r7r8�__repr__gs�zSysCaptureBase.__repr__�op�states.cC�(|j|vsJd�||jd�|����dS�Nz+cannot {} in state {!r}: expected one of {}z, �r�r��join�ryr�r�r7r7r8�
_assert_statep�
��zSysCaptureBase._assert_statecC�&|�dd�tt|j|j�d|_dS)Nr��r��started)r��setattrr#rzr�r�rxr7r7r8r�w�
zSysCaptureBase.startcCsB|�dd�|jdkr
dStt|j|j�|`|j��d|_dS)Nr��r�r��	suspendedr�)r�r�r�r#rzr�r�r�rxr7r7r8r�|s


zSysCaptureBase.donecCr��Nr��r�r�r�)r�r�r#rzr�r�rxr7r7r8r��r�zSysCaptureBase.suspendcCs4|�dd�|jdkr
dStt|j|j�d|_dS�Nr�r�r�)r�r�r�r#rzr�rxr7r7r8r��s


zSysCaptureBase.resumervr�)r~rr�r�rrr�r�r�rwr�rr�r�r�r�r�r7r7r7r8r�Os(�����
�		


	r�c@�0eZdZdZdefdd�Zdeddfdd�ZdS)	�SysCaptureBinary�r'cC�>|�dd�|j�d�|jj��}|j�d�|j��|S�Nr�r�r�r�r�r�rBr�r��ry�resr7r7r8r���
zSysCaptureBinary.snapr�NcCs4|�dd�|j��|jj�|�|jj��dS�Nr�r�)r�r�r�rBrnr�r7r7r8r��s
zSysCaptureBinary.writeorg)r~rr�r��bytesr�r�r7r7r7r8r���r�c@r�)	�
SysCapturer|r'cCs@|�dd�t|jt�sJ�|j��}|j�d�|j��|Sr�)r�rYr�r�r�r�r�r�r7r7r8r��s

zSysCapture.snapr�NcCs&|�dd�|j�|�|j��dSr�)r�r�rnr�r�r7r7r8r��szSysCapture.writeorg)r~rr�r�r�r�r�r7r7r7r8r�rrc@sreZdZdeddfdd�Zdefdd�Zded	eed
fddfdd�Zdd
d�Z	ddd�Z
ddd�Zddd�ZdS)�
FDCaptureBase�targetfdr'NcCs�||_zt�|�Wnty#t�tjtj�|_t�|j|�Ynwd|_t�	|�|_
|dkr?ttjdd�|_t|�|_
nttdd�ddddd�|_|tvrXt||j�|_
nt|�|_
d	|_dS)
Nr�utf-8)rL)rRr}r|T)rLrMr�r�r�)rrI�fstatr�rH�devnull�O_RDWR�targetfd_invalid�dup2rJ�
targetfd_saver�r�
syscapturerurr�r�r�)ryrr7r7r8r��s.��

zFDCaptureBase.__init__cCsd�|jj|j|j|j|j�S)Nz)<{} {} oldfd={} _state={!r} tmpfile={!r}>)r�r�r~rr
r�r�rxr7r7r8r��s�zFDCaptureBase.__repr__r�r�.cCr�r�r�r�r7r7r8r��r�zFDCaptureBase._assert_statecCs4|�dd�t�|j��|j�|j��d|_dS)z4Start capturing on targetfd using memorized tmpfile.r�r�r�N)	r�rIr	r�rKrrr�r�rxr7r7r8r��s

zFDCaptureBase.startcCs�|�dd�|jdkr
dSt�|j|j�t�|j�|jdur2|j|jkr,t�|j�t�|j�|j�	�|j
��d|_dS)z_Stop capturing, restore streams, return original capture file,
        seeked to position zero.r�r�N)r�r�rIr	r
rr�rrr�r�rxr7r7r8r��s




zFDCaptureBase.donecCs>|�dd�|jdkr
dS|j��t�|j|j�d|_dSr�)r�r�rr�rIr	r
rrxr7r7r8r�s


zFDCaptureBase.suspendcCsB|�dd�|jdkr
dS|j��t�|j��|j�d|_dSr�)	r�r�rr�rIr	r�rKrrxr7r7r8r�s


zFDCaptureBase.resumer�)
r~rr�r�r�r�r�rr�r�r�r�r�r7r7r7r8r�s)	


rc@�4eZdZdZdZdefdd�Zdeddfdd	�ZdS)
�FDCaptureBinaryzWCapture IO to/from a given OS-level file descriptor.

    snap() produces `bytes`.
    r�r'cCr�r�r�r�r7r7r8r�r�zFDCaptureBinary.snapr�NcCs|�dd�t�|j|�dS)�"Write to original file descriptor.r�r�N)r�rIrnr
r�r7r7r8r�'szFDCaptureBinary.writeorg)r~rr��__doc__r�r�r�r�r7r7r7r8r
�
r
c@r)
�	FDCapturezTCapture IO to/from a given OS-level file descriptor.

    snap() produces text.
    r|r'cCs<|�dd�|j�d�|j��}|j�d�|j��|Sr�)r�r�r�r�r�r�r7r7r8r�5s

zFDCapture.snapr�NcCs$|�dd�t�|j|�d��dS)rr�r�rN)r�rIrnr
�encoder�r7r7r8r�=szFDCapture.writeorg)r~rr�rr�r�r�r�r7r7r7r8r-rr)��c@s"eZdZUdZeed<eed<dS)�
CaptureResult�2The result of :method:`CaptureFixture.readouterr`.rrrsN)r~rr�rrr�r7r7r7r8rJs
rc@seZdZdZdZdS)rrr7N)r~rr�rr�r7r7r7r8rSsrrrsc@s�eZdZdZdZdeeedeeedeeeddfdd�Zde	fd	d
�Z
ddd�Zdeeeffd
d�Z
ddeddfdd�Zddd�Zddd�Zdefdd�Zdeefdd�ZdS)�MultiCaptureNF�in_rrrsr'cCs||_||_||_dSrv�rrrrs)ryrrrrsr7r7r8r�_s
zMultiCapture.__init__cCsd�|j|j|j|j|j�S)NzH<MultiCapture out={!r} err={!r} in_={!r} _state={!r} _in_suspended={!r}>)r�rrrsrr��
_in_suspendedrxr7r7r8r�is�zMultiCapture.__repr__cCs>d|_|jr|j��|jr|j��|jr|j��dSdS)Nr�)r�rr�rrrsrxr7r7r8�start_capturingrs

�zMultiCapture.start_capturingcCsP|��\}}|r|jdusJ�|j�|�|r$|jdusJ�|j�|�||fS)z?Pop current snapshot out/err capture and flush to orig streams.N)�
readouterrrrr�rs�ryrrrsr7r7r8�pop_outerr_to_orig{szMultiCapture.pop_outerr_to_origcCsLd|_|jr|j��|jr|j��|r"|jr$|j��d|_dSdSdS)Nr�T)r�rrr�rsrr�ryrr7r7r8�suspend_capturing�s




�zMultiCapture.suspend_capturingcCsRd|_|jr|j��|jr|j��|jr'|jdusJ�|j��d|_dSdS)Nr�F)r�rrr�rsrrrxr7r7r8�resume_capturing�s



�zMultiCapture.resume_capturingcCsP|jdkr	td��d|_|jr|j��|jr|j��|jr&|j��dSdS)z+Stop capturing and reset capturing streams.�stoppedzwas already stoppedN)r��
ValueErrorrrr�rsrrxr7r7r8�stop_capturing�s


�zMultiCapture.stop_capturingcCs
|jdkS)z7Whether actively capturing -- not suspended or stopped.r�)r�rxr7r7r8�
is_started�s
zMultiCapture.is_startedcCs2|jr|j��nd}|jr|j��nd}t||�Sr�)rrr�rsrrr7r7r8r�s
zMultiCapture.readouterrr��F)r~rr�r�rrr�rr�r�r�rrrr�r r!r$r%rrr7r7r7r8r[s(
�
�
�
�

		


rr*�_CaptureMethodcCs�|dkrttd�td�td�d�S|dkr"ttd�td�td�d�S|dkr-tdddd�S|dkr@tdtdd	d
�tdd	d
�d�Std|����)Nr"rr�r�rr#r$r%Tr�zunknown capturing method: )rrrr#)r*r7r7r8�_get_multicapture�s�r(c@s�eZdZdZdCdd�Zdefdd	�Zdeeeffd
d�Z	defdd
�Z
dDdd�ZdDdd�ZdDdd�Z
dEdeddfdd�ZdEdeddfdd�ZdDdd�Zdeefdd�ZdFd d!�ZdDd"d#�ZdDd$d%�ZdDd&d'�ZdDd(d)�ZdDd*d+�Zejded,fd-d.��Zejd/ed0eded,fd1d2��Zed3d4�d5e fd6d7��Z!ed3d4�d0eded,fd8d9��Z"ed3d4�d0eded,fd:d;��Z#ed3d4�d0eded,fd<d=��Z$ed3d>�dDd?d@��Z%ed3d>�dDdAdB��Z&dS)Grfa�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*r'r'NcCs||_d|_d|_dSrv)�_method�_global_capturing�_capture_fixture)ryr*r7r7r8r��s
zCaptureManager.__init__cCsd�|j|j|j�S)NzJ<CaptureManager _method={!r} _global_capturing={!r} _capture_fixture={!r}>)r�r)r*r+rxr7r7r8r��s�zCaptureManager.__repr__cCs$|��rdS|jrd|jjjSdS)N�globalz
fixture %sF)�is_globally_capturingr+�request�fixturenamerxr7r7r8�is_capturing�s
zCaptureManager.is_capturingcCs
|jdkS)Nr$)r)rxr7r7r8r-��
z$CaptureManager.is_globally_capturingcCs(|jdusJ�t|j�|_|j��dSrv)r*r(r)rrxr7r7r8rj�sz%CaptureManager.start_global_capturingcCs,|jdur|j��|j��d|_dSdSrv)r*rr$rxr7r7r8ri�s




�z$CaptureManager.stop_global_capturingcCs|jdur|j��dSdSrv)r*r!rxr7r7r8�resume_global_capture�s
�z$CaptureManager.resume_global_captureFrcCs |jdur|jj|d�dSdS)N�r)r*r rr7r7r8rk�s
�z%CaptureManager.suspend_global_capturecCs|��|�|�dSrv)�suspend_fixturerkrr7r7r8r�szCaptureManager.suspendcCs|��|��dSrv)r2�resume_fixturerxr7r7r8r�szCaptureManager.resumecCs|jdusJ�|j��Srv)r*rrxr7r7r8rm
s
z"CaptureManager.read_global_capture�capture_fixture�CaptureFixture[Any]cCs6|jr|jjj}|jj}|j�d�||��||_dS)Nz%cannot use {} and {} at the same time)r+r.r/�
raiseerrorr�)ryr6�current_fixture�requested_fixturer7r7r8�set_fixtures
��
zCaptureManager.set_fixturecCs
d|_dSrv)r+rxr7r7r8�
unset_fixturer1zCaptureManager.unset_fixturecC�|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+�_startrxr7r7r8�activate_fixtures�zCaptureManager.activate_fixturecCr=)zDDeactivate the ``capsys`` or ``capfd`` fixture of this item, if any.N)r+r�rxr7r7r8�deactivate_fixture$s�z!CaptureManager.deactivate_fixturecC�|jr
|j��dSdSrv)r+�_suspendrxr7r7r8r4)��zCaptureManager.suspend_fixturecCrArv)r+�_resumerxr7r7r8r5-rCzCaptureManager.resume_fixture�NNNccs��|jo|j��}|r|��|jo|j��}|r|��zdVW|r(|��|r0|��dSdS|r8|��|r?|��ww)zLContext manager to temporarily disable global and current fixture capturing.N)r+�_is_startedr4r*r%rkr2r5)ry�
do_fixture�	do_globalr7r7r8�global_and_fixture_disabled3s&���
�z*CaptureManager.global_and_fixture_disabled�when�itemc	cst�|��|��zdVW|��|jdd�n|��|jdd�w|��\}}|�|d|�|�|d|�dS)NFr3r\r])r2r?r@rkrm�add_report_section)ryrJrKrrrsr7r7r8�item_captureDs��zCaptureManager.item_captureTr`�	collectorccsp�t|t�r3|��dV}|��|��\}}|��}|r%|j�d|f�|r1|j�d|f�dSdSdVdS)NzCaptured stdoutzCaptured stderr)rYrr2rkrm�
get_result�sections�append)ryrNrqrrrs�repr7r7r8�pytest_make_collect_reportTs�
�
z)CaptureManager.pytest_make_collect_reportcc�:�|�d|��dVWd�dS1swYdS)N�setup�rM�ryrKr7r7r8�pytest_runtest_setupc��"�z#CaptureManager.pytest_runtest_setupccrT)N�callrVrWr7r7r8�pytest_runtest_callhrYz"CaptureManager.pytest_runtest_callccrT)N�teardownrVrWr7r7r8�pytest_runtest_teardownmrYz&CaptureManager.pytest_runtest_teardown)�tryfirstcC�|��dSrv�rirxr7r7r8�pytest_keyboard_interruptr�z(CaptureManager.pytest_keyboard_interruptcCr_rvr`rxr7r7r8�pytest_internalerrorvrbz#CaptureManager.pytest_internalerror)r*r'r'Nr�r&)r6r7r'N)'r~rr�rr�r�r�rr�r0r-rjrir2rkr�r�rrmr;r<r?r@r4r5�
contextlib�contextmanagerr	rIrrMrrrSrXr[r]rarcr7r7r7r8rf�sF
	









rfc	@s�eZdZdZdd�deeedededdfd	d
�Z	ddd�Z
dd
d�Zdeefdd�Z
ddd�Zddd�Zdefdd�Zejdedfdd��ZdS)�CaptureFixturez|Object returned by the :fixture:`capsys`, :fixture:`capsysbinary`,
    :fixture:`capfd` and :fixture:`capfdbinary` fixtures.F��	_ispytest�captureclassr.rhr'NcCs2t|�||_||_d|_|jj|_|jj|_dSrv)rrir.�_capturer��
_captured_out�
_captured_err)ryrir.rhr7r7r8r�s
zCaptureFixture.__init__cCs8|jdurtd|�d�|�d�d�|_|j��dSdS)Nr�r�r)rjrrirrxr7r7r8r>�s
��zCaptureFixture._startcCsL|jdur$|j��\}}|j|7_|j|7_|j��d|_dSdSrv)rjrrkrlr$rr7r7r8r��s


�zCaptureFixture.closecCsT|j|j}}|jdur|j��\}}||7}||7}|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.
        N)rkrlrjrrir�r)ry�captured_out�captured_errrrrsr7r7r8r�s



zCaptureFixture.readouterrcC�|jdur|j��dSdS)z1Suspend this fixture's own capturing temporarily.N)rjr rxr7r7r8rB��
�zCaptureFixture._suspendcCro)z0Resume this fixture's own capturing temporarily.N)rjr!rxr7r7r8rD�rpzCaptureFixture._resumecCs|jdur
|j��SdS)z5Whether actively capturing -- not disabled or closed.NF)rjr%rxr7r7r8rF�s

zCaptureFixture._is_startedrEccsF�|jjj�d�}|���dVWd�dS1swYdS)z>Temporarily disable capturing while inside the ``with`` block.rcN)r.�configre�	getpluginrI)ry�
capmanagerr7r7r8�disabled�s�
�
"�zCaptureFixture.disabledr�)r~rr�rrr�rrr�r�r>r�rrrBrDrFrdrer	rtr7r7r7r8rf{s(�
���
�

	

rfr.cc�J�|jj�d�}tt|dd�}|�|�|��|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"
    rcTrgN)	rqrerrrfrr;r>r�r<�r.rpr6r7r7r8�capsys���
rwccru)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"
    rcTrgN)	rqrerrrfr�r;r>r�r<rvr7r7r8�capsysbinary�rxryccru)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"
    rcTrgN)	rqrerrrfrr;r>r�r<rvr7r7r8�capfdrxrzccru)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"

    rcTrgN)	rqrerrrfr
r;r>r�r<rvr7r7r8�capfdbinary s�
r{r�)Prr��collectionsrdrFrIr#r�tempfiler�typesr�typingrrrr	r
rrr
rrrrrrr�_pytest.compatr�_pytest.configrr�_pytest.config.argparsingr�_pytest.deprecatedr�_pytest.fixturesrr�
_pytest.nodesrrr�typing_extensionsrr r'r9r?r_rtrGrur�r�r��ABCr�r�r�r�r�r�r�rrr
r�version_infor�
namedtuplerr(rfrfrwryrzr{r7r7r7r8�<module>s�
8	
O Cb
�W9Q"""&