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__/twisted.cpython-311.pyc

�

�܋f3���UdZddlmZddlmZmZmZddlmZddl	m
Z
ddlmZddl
mZmZmZGd	�d
e��ZejZe
ed<ejZe
ed<ejZe
ed
<ejZe
ed<ejZe
ed<dS)z1
Tools for helping to test Twisted applications.
�)�pformat)�Union�Sequence�Callable)�TestCase)�
NamedConstant�)�compare)�globalLogPublisher�formatEvent�LogLevelc��eZdZdZdeffdeeeeffd�Z	d�Z
d�Zd�Zdd	�d
e
fd�Zddededefd�Zddefd�Zedefd���ZdS)�
LogCapturea5
    A helper for capturing stuff logged using Twisted's loggers.

    :param fields:
      A sequence of field names that :meth:`~LogCapture.check` will use to build
      "actual" events to compare against the expected events passed in.
      If items are strings, they will be treated as keys info the Twisted logging event.
      If they are callable, they will be called with the event as their only parameter.
      If only one field is specified, "actual" events will just be that one field;
      otherwise they will be a tuple of the specified fields.
    �	log_level�fieldsc�"�g|_||_dS�N)�eventsr)�selfrs  �e/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/testfixtures/twisted.py�__init__zLogCapture.__init__s����������c�:�|j�|��dSr)r�append)r�events  r�__call__zLogCapture.__call__ s������5�!�!�!�!�!rc�B�tj|_|gt_dS)zStart capturing.N)r�
_observers�original_observers�rs r�installzLogCapture.install#s��"4�"?���)-���%�%�%rc�(�|jt_dS)zStop capturing.N)rrrr s r�	uninstallzLogCapture.uninstall(s��(,�(?��%�%�%rT)�
order_mattersr$c
�b�	�g}|jD]R�	t�	fd�|jD����}t|��dkr|d}|�|���S|rt||���dSt
|��}g}g}|D]e}	|�|��}|�|�|�����A#t$r|�|��Y�bwxYw|r?tdt|���dt|���dt|�������dS)	aE
        Check captured events against those supplied. Please see the ``fields`` parameter
        to the constructor to see how "actual" events are built.

        :param order_matters:
          This defaults to ``True``. If ``False``, the order of expected logging versus
          actual logging will be ignored.
        c3�v�K�|]3}t|��r|���n��|��V��4dSr)�callable�get)�.0�fieldrs  �r�	<genexpr>z#LogCapture.check.<locals>.<genexpr>7s[�����!6�!6� %�2:�%���!V���u����e�i�i�PU�FV�FV�!6�!6�!6�!6�!6�!6rr	r)�expected�actualz.entries not as expected:

expected and found:
z

expected but not found:
z

other entries:
N)r�tupler�lenrr
�list�index�pop�
ValueError�AssertionErrorr)
rr$r,r-�actual_event�matched�	unmatched�entryr1rs
         @r�checkzLogCapture.check,s�������[�	(�	(�E� �!6�!6�!6�!6�)-��!6�!6�!6�6�6�L��<� � �A�%�%�+�A����M�M�,�'�'�'�'��	O��X�f�5�5�5�5�5�5��H�~�~�H��G��I��
8�
8��8�$�N�N�5�1�1�E��N�N�8�<�<��#6�#6�7�7�7�7��"�,�,�,��$�$�U�+�+�+�+�+�,�����
O�$�n�
�W�%�%�%�%�w�x�'8�'8�'8�'8�'�)�:L�:L�:L�&N�O�O�O�
O�
Os�C	�	C+�*C+����valuer,r1�	attributec	��t|tt|j|d|�������dS)ai
        Check the string representation of an attribute of a logged ``Failure`` is as expected.

        :param expected: The expected string representation.
        :param index: The index into :attr:`events` where the failure should have been logged.
        :param attribute: The attribute of the failure of which to find the string representation.
        �log_failure)r-N)r
�str�getattrr)rr,r1r<s    r�check_failure_textzLogCapture.check_failure_textQs<��	���W�T�[��-?�
�-N�PY�%Z�%Z�![�![�\�\�\�\�\�\rr�start_indexc�\�|j|d�D]}|�d��}|r|��dS)z�
        A debugging tool that raises the first failure encountered in captured logging.

        :param start_index: The index into :attr:`events` from where to start looking for failures.
        Nr>)rr()rrBr�failures    r�raise_logged_failurezLogCapture.raise_logged_failure[sK���[����.�	�	�E��i�i�
�.�.�G��
��
�
�	�	r�testcasec�r�|di|��}|���|�|j��|S)a]
        Instantiate, install and add a cleanup for a :class:`LogCapture`.

        :param testcase: This must be an instance of :class:`twisted.trial.unittest.TestCase`.
        :param kw: Any other parameters are passed directly to the :class:`LogCapture` constructor.
        :return: The :class:`LogCapture` instantiated by this method.
        �)r!�
addCleanupr#)�clsrF�kw�captures    r�makezLogCapture.makefsA���#�)�)��)�)�����������G�-�.�.�.��rN)r:r;)r)�__name__�
__module__�__qualname__�__doc__rrrr?rrrr!r#�boolr9�intrArE�classmethodrrMrHrrrrs7������
�
�BM�k�@[���x��c�8�m�(<�=�����
"�"�"�/�/�/�
@�@�@�6:�#O�#O�#O�d�#O�#O�#O�#O�J]�]�3�]�s�]�C�]�]�]�]�	�	��	�	�	�	���H�����[���rr�DEBUG�INFO�WARN�ERROR�CRITICALN)rQ�pprintr�typingrrr�unittestr�
constantlyr�r
�twisted.loggerrrr
�objectr�debugrU�__annotations__�inforV�warnrW�errorrX�criticalrYrHrr�<module>rgs0�����������,�,�,�,�,�,�,�,�,�,�������$�$�$�$�$�$�������D�D�D�D�D�D�D�D�D�D�d�d�d�d�d��d�d�d�P �~��}�%�%�%��m��m�#�#�#��m��m�#�#�#��~��}�%�%�%�"�+��-�+�+�+�+�+r

Hacked By AnonymousFox1.0, Coded By AnonymousFox