Hacked By AnonymousFox

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

�

�܋f���V�ddlZddlZddlmZddlmZddlmZGd�de��Z	dS)�N)�StringIO)�
TemporaryFile)�comparec��eZdZdZdZdZddededefd�Zd	�Zd
�Z	d�Z
d�Zd
�Ze
defd���Zddededefd�ZdS)�
OutputCapturea�
    A context manager for capturing output to the
    :any:`sys.stdout` and :any:`sys.stderr` streams.

    :param separate: If ``True``, ``stdout`` and ``stderr`` will be captured
                     separately and their expected values must be passed to
                     :meth:`~OutputCapture.compare`.

    :param fd: If ``True``, the underlying file descriptors will be captured,
               rather than just the attributes on :mod:`sys`. This allows
               you to capture things like subprocesses that write directly
               to the file descriptors, but is more invasive, so only use it
               when you need it.

    :param strip_whitespace:
        When ``True``, which is the default, leading and training whitespace
        is trimmed from both the expected and actual values when comparing.

    .. note:: If ``separate`` is passed as ``True``,
              :attr:`OutputCapture.captured` will be an empty string.
    NFT�separate�fd�strip_whitespacec�0�||_||_||_dS�N)rr	r
)�selfrr	r
s    �k/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/testfixtures/outputcapture.py�__init__zOutputCapture.__init__#s�� ��
���� 0�����c�"�|jr:t��|_t��|_t��|_n9t��|_t��|_t��|_|���|Sr)r	r�output�stdout�stderrr�enable�r
s r�	__enter__zOutputCapture.__enter__(sb���7�	%�'�/�/�D�K�'�/�/�D�K�'�/�/�D�K�K�"�*�*�D�K�"�*�*�D�K�"�*�*�D�K����
�
�
��rc�.�|���dSr)�disable)r
�argss  r�__exit__zOutputCapture.__exit__4s���������rc�*�|jri|jtjf|jtjffD]@\}}t
j||�����t
j	|���AdS|jt_|jt_dS)z,Disable the output capture if it is enabled.N)
r	�original_stdout�sysr�original_stderrr�os�dup2�fileno�close)r
�original�currents   rrzOutputCapture.disable7s����7�
	.��%�s�z�2��%�s�z�2�&�
#�
#�!��'����'�.�.�"2�"2�3�3�3����"�"�"�"�
#�
#��-�C�J��-�C�J�J�Jrc�0�|j��|jrktjtj�����|_tjtj�����|_n"tj|_tj|_|j	r�|jr�tj
|j���tj�����tj
|j���tj�����dS|jt_|jt_dS|jr�tj
|j���tj�����tj
|j���tj�����dS|jxt_t_dS)z,Enable the output capture if it is disabled.N)rr	r �duprrr"rrrr!rrs rrzOutputCapture.enableEsx����'��w�
2�')�v�c�j�.?�.?�.A�.A�'B�'B��$�')�v�c�j�.?�.?�.A�.A�'B�'B��$�$�'*�z��$�'*�z��$��=�	6��w�
)�����*�*�,�,�c�j�.?�.?�.A�.A�B�B�B�����*�*�,�,�c�j�.?�.?�.A�.A�B�B�B�B�B�!�[��
�!�[��
�
�
��w�
6�����*�*�,�,�c�j�.?�.?�.A�.A�B�B�B�����*�*�,�,�c�j�.?�.?�.A�.A�B�B�B�B�B�*.�+�5��
�S�Z�Z�Zrc��|jr;|�d��|������S|���S)Nr)r	�seek�read�decode�getvalue)r
�streams  r�_readzOutputCapture._read\sE���7�	%��K�K��N�N�N��;�;�=�=�'�'�)�)�)��?�?�$�$�$r�returnc�6�|�|j��S)z?A property containing any output that has been captured so far.)r.rrs r�capturedzOutputCapture.capturedcs���z�z�$�+�&�&�&r��expectedrrc��i}i}d||jfd||�|j��fd||�|j��ffD]E\}}}|jr(|���}|���}||kr
|||<|||<�Ft
|��dkr[tt|�	����dt|�	����d���t||���dS)a�
        Compare the captured output to that expected. If the output is
        not the same, an :class:`AssertionError` will be raised.

        :param expected: A string containing the expected combined output
                         of ``stdout`` and ``stderr``.

        :param stdout: A string containing the expected output to ``stdout``.

        :param stderr: A string containing the expected output to ``stderr``.
        r1rr�r)r3�actualN)
r1r.rrr
�strip�lenr�tuple�values)	r
r3rr�expected_mapping�actual_mapping�prefix�	_expectedr1s	         rrzOutputCapture.comparehs,�������X�t�}�5��6�4�:�:�d�k�#:�#:�;��6�4�:�:�d�k�#:�#:�;�,
�
	2�
	2�'�F�I�x�
�$�
,�%�O�O�-�-�	�#�>�>�+�+���H�$�$�+4� ��(�)1��v�&���� � �A�%�%��U�#3�#:�#:�#<�#<�=�=�a�@� ��!6�!6�!8�!8�9�9�!�<�
>�
>�
>�
>��)�.�A�A�A�A�A�Ar)FFT)r2r2r2)�__name__�
__module__�__qualname__�__doc__rr�boolrrrrrr.�property�strr1r�rrrr	s��������,�O��O�1�1��1�4�1�SW�1�1�1�1�

�
�
����.�.�.�6�6�6�.%�%�%��'�#�'�'�'��X�'�B�B��B�#�B�C�B�B�B�B�B�Brr)
r r�ior�tempfiler�testfixtures.comparisonr�objectrrFrr�<module>rKs���	�	�	�	�
�
�
�
�������"�"�"�"�"�"�+�+�+�+�+�+�{B�{B�{B�{B�{B�F�{B�{B�{B�{B�{Br

Hacked By AnonymousFox1.0, Coded By AnonymousFox