%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/logger/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/logger/test/__pycache__/test_logger.cpython-312.pyc

�

Ϫ�f ����dZddlmZmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZdd
lmZmZddlmZGd�d
e�ZGd�d�ZGd�dej4�Zy)z+
Test cases for L{twisted.logger._logger}.
�)�List�Optional�Type�cast)�implementer)�
NamedConstant)�unittest�)�formatEvent)�globalLogPublisher)�ILogObserver�LogEvent)�InvalidLogLevelError�LogLevel��Loggerc	�2�eZdZdZ	ddedeededdfd�Zy)	�
TestLoggerz^
    L{Logger} with an overridden C{emit} method that keeps track of received
    events.
    N�level�format�kwargs�returnc���tt�dtddf�fd��}tj|�	tj�||fi|��tj|�|||d��_y#tj|�wxYw)N�eventrc���|�_y�N)r�r�selfs ��A/usr/lib/python3/dist-packages/twisted/logger/test/test_logger.py�observerz!TestLogger.emit.<locals>.observers
����D�J�)rrr)	rr
rr�addObserverr�emit�removeObserver�emitted)rrrrr s`    rr#zTestLogger.emits����
�\�	"�	�H�	��	�
#�	�	�&�&�x�0�	8��K�K��e�V�6�v�6��-�-�h�7����
����
�-�-�h�7�s�A1�1Br)	�__name__�
__module__�__qualname__�__doc__rr�str�objectr#�r!rrrs6���=A�
�"�
�,4�S�M�
�LR�
�	
�
r!rc�B�eZdZdZe�Zddeeddfd�Zdefd�Z	y)�LogComposedObjectz3
    A regular object, with a logger attached.
    N�staterc��||_yr�r/)rr/s  r�__init__zLogComposedObject.__init__7s	����
r!c�"�d|j�d�S)Nz<LogComposedObject �>r1)rs r�__str__zLogComposedObject.__str__:s��$�T�Z�Z�L��2�2r!r)
r&r'r(r)r�logrr*r2r5r,r!rr.r.0s3����,�C��h�s�m��t��3��3r!r.c��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zdd�Zdd�Z
dd
�Zdd�Zdd�Zdd�Zy)�LoggerTestsz
    Tests for L{Logger}.
    Nc�n�d}t|�}|jt|�dt|��d��y)z"
        repr() on Logger
        �blearghz<Logger r4N)r�assertEqual�repr)r�	namespacer6s   r�	test_reprzLoggerTests.test_reprCs5���	��Y�������c��h�t�I��.?�q�$A�Br!c�X�t�}|j|jt�y)z3
        Default namespace is module name.
        N)rr;r=r&�rr6s  r�test_namespaceDefaultz!LoggerTests.test_namespaceDefaultKs���h���������1r!c��g}tdtt��t��|j	|dj
d�y)z�
        Default namespace is C{"<unknown>"} when a logger is created from a
        context in which is can't be determined automatically and no namespace
        was specified.
        zresult.append(Logger())rrz	<unknown>N)�exec�dictr�localsr;r=)r�results  r�test_namespaceOMGItsTooHardz'LoggerTests.test_namespaceOMGItsTooHardRs=�� "���%�����H�	
�
	
������,�,�k�:r!c��t�}dj|j|jj�}|jt
t|j�j|�|jt
tttj�j|�|jt
tttj�jt�|jt
t|j�j|�|jt�j�y)z�
        Default namespace for classes using L{Logger} as a descriptor is the
        class name they were retrieved from.
        z{}.{}N)r.rr'�	__class__r&r;rrr6r=r�assertIs�source�assertIsNoner)r�obj�expectedNamespaces   r�test_namespaceAttributez#LoggerTests.test_namespaceAttribute`s���
 �!��#�N�N��N�N��M�M�"�"�
��
	
����j�#�'�'�2�<�<�>O�P������j�!�#4�#8�#8�9�C�C�EV�	
�	
�
�
���j�!�#4�#8�#8�9�@�@�BS�	
�	
�
�
�d�:�s�w�w�/�6�6��<����&�(�/�/�*r!c���g�G�fd�d�}|jjd�|jt��d�|j�ddd�y)zH
        When used as a descriptor, the observer is propagated.
        c�D��eZdZeeeW�j���Zy)�5LoggerTests.test_descriptorObserver.<locals>.MyObject�r N)r&r'r(rrr
�appendr6)�observeds�r�MyObjectrR|s����$�|�X�_�_�"E�F�Cr!rV�hello�r�
log_formatN)r6�infor;�len)rrVrUs  @r�test_descriptorObserverz#LoggerTests.test_descriptorObservervsW���$&��	G�	G�	�����'�"�����X���*�����!��\�2�G�<r!c�4�td�}tt|j�}|j	d�|jd|j�|j|jd|�t|j�}|jd|�y)z�
        On instances that have a L{Logger} class attribute, the C{log_source}
        key is available to format strings.
        rWzHello, {log_source}.�
log_sourcez!Hello, <LogComposedObject hello>.N)	r.rrr6�error�assertInrr;r)rrMr6�stuffs    r�!test_sourceAvailableForFormattingz-LoggerTests.test_sourceAvailableForFormatting�ss��
 ��(���:�s�w�w�'���	�	�(�)��
�
�l�C�I�I�.�������<�0�#�6��C�I�I�&���
�
�9�5�Ar!c�^�t�}tj�D�]�}d}|j|j��}t||j�}||||j��|j
|jd|�|j
|jd|�|j
|jdd|�|jt|d�d	�|j
|jd
|�|j
|jd|�|j
|jdt�|j|jd
�|j
|jd|�|j
t|j�|����y)z]
        Test that log levels and messages are emitted correctly for
        Logger.
        zThis is a {level_name} message)�
level_name)�junkrdrrrrerzNo event observed.rY�	log_level�
log_namespacer^N)rr�
iterconstantsr�name�getattrr;r%�
assertTrue�hasattrrr&rLr)rr6rr�message�	logMethods      r�test_basicLoggerzLoggerTests.test_basicLogger�sX��
�l���+�+�-�	>�E�5�F��m�m�u�z�z�m�:�G���U�Z�Z�0�I��f�7�u�z�z�B�
���S�[�[��1�5�9����S�[�[��2�F�;����S�[�[��2�6�:�G�D��O�O�G�C��1�3G�H����S�Y�Y�|�4�f�=����S�Y�Y�{�3�U�;����S�Y�Y��7��B����c�i�i��5�6����S�Y�Y�v�.��8����[����3�W�=�)	>r!c�����tt�dtddf��fd���G�fd�d��tt�j
�j
�y)z>
        C{log_source} event key refers to the class.
        rrNc�0���j|d��y�Nr^�r;)r�Thingors ��rr z0LoggerTests.test_sourceOnClass.<locals>.observer��������U�<�0�&�9r!c�"��eZdZeW���Zy)�.LoggerTests.test_sourceOnClass.<locals>.ThingorSN�r&r'r(rr6rSs�rrtrw��
����h�/�Cr!rt�rr
rrrr6rZ)rrtr s`@@r�test_sourceOnClasszLoggerTests.test_sourceOnClass�sM���

�\�	"�	:�H�	:��	:�
#�	:�	0�	0�	
�Z����$�)�)�+r!c������tt�dtddf��fd���G�fd�d�}|��tt�j
�j
�y)zA
        C{log_source} event key refers to the instance.
        rrNc�0���j|d��yrrrs)rr�thingos ��rr z3LoggerTests.test_sourceOnInstance.<locals>.observer�rur!c�"��eZdZeW���Zy)�1LoggerTests.test_sourceOnInstance.<locals>.ThingorSNrxrSs�rrtr��ryr!rtrz)rrtr r~s` @@r�test_sourceOnInstancez!LoggerTests.test_sourceOnInstance�sT���

�\�	"�	:�H�	:��	:�
#�	:�	0�	0�����Z����$�)�)�+r!c�~��tt�dtddf�fd��}t|��}|j	�y)z5
        C{log_source} event key is L{None}.
        rrNc�.���j|d�yrr)rLrs �rr z0LoggerTests.test_sourceUnbound.<locals>.observer�s������e�L�1�2r!rS�rr
rrrZ)rr r6s`  r�test_sourceUnboundzLoggerTests.test_sourceUnbound�s?���

�\�	"�	3�H�	3��	3�
#�	3��(�+�����
r!c�h�t�}	td��#t$r|jd�YnwxYw|jt�}|j	t|�d�|j	|jdtj�|j	|jdd�y)z?
        Test that log.failure() emits the right data.
        zbaloney!�WhoopsrXrrN)	r�RuntimeError�failure�flushLoggedErrorsr;r[r%r�critical�rr6�errorss   r�test_defaultFailurezLoggerTests.test_defaultFailure�s����l��	"��z�*�*���	"��K�K��!�	"���'�'��5������V��a�(�������W�-�x�/@�/@�A�������X�.��9s��4�4c��t�}|jddtjdd��|j	|j
dd�|j	|j
dtj�|j	|j
d|j�|j|j
d	�y
)zQ
        Make sure that kwargs conflicting with args don't pass through.
        �*�#z*namespace*z*source*)rYrfrgr^rYrfrgr^N)r�warnrr_r;rr=rLr@s  r�test_conflictingKwargsz"LoggerTests.test_conflictingKwargs�s����l��������n�n�'�!�	�	
�	
������<�0�#�6�������;�/����?�������?�3�S�]�]�C����#�)�)�L�1�2r!c��t�}|jd�|jt�}|j	t|�d�y)zA
        Test passing in a bogus log level to C{emit()}.
        z*bogus*rXN)rr#r�rr;r[r�s   r�test_logInvalidLogLevelz#LoggerTests.test_logInvalidLogLevel�s<���l��������'�'�(<�=������V��a�(r!c�������tt�dtddf�fd���tt�dtddf���fd���t�����j	dg��y)	zE
        Tracing keeps track of forwarding to the publisher.
        rrNc����|�yrr,)rr s �r�	publisherz)LoggerTests.test_trace.<locals>.publishers
����U�Or!c�6���j|d��fg�y)N�	log_tracers)rr6r�rs ���rr z(LoggerTests.test_trace.<locals>.observers ������U�;�/�3�	�2B�1C�Dr!rSzHello.)r�r�)rr6r r�s`@@@r�
test_tracezLoggerTests.test_tracesq���

�\�	"�	�X�	�$�	�
#�	�
�\�	"�	E�H�	E��	E�
#�	E��)�,������R��(r!)rN)r&r'r(r)r>rArGrOr\rbror{r�r�r�r�r�r�r,r!rr8r8>sO���C�2�;�+�,=�
B�>�:,�
,�
�:� 3�&	)�)r!r8N)r)�typingrrrr�zope.interfacer�
constantlyr�
twisted.trialr	�_formatr�_globalr�_interfacesr
r�_levelsrr�_loggerrrr.�TestCaser8r,r!r�<module>r�sT���.�-�&�$�"�!�(�0�4��
��
�43�3�V)�(�#�#�V)r!

Zerion Mini Shell 1.0