%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_file.cpython-312.pyc

�

Ϫ�f�����dZddlmZddlmZddlmZmZmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZd	d
lmZmZd	dlmZGd�d
e�ZGd�de�ZGd�d�Zy)z)
Test cases for L{twisted.logger._file}.
�)�StringIO)�
TracebackType)�IO�Any�AnyStr�Optional�Type�cast)�BrokenMethodImplementation)�verifyObject)�Failure)�TestCase�)�FileLogObserver�textFileLogObserver)�ILogObserverc�R�eZdZdZdd�Zdd�Zdeededdfd�Z	dd	�Z
dd
�Zdd�Zy)
�FileLogObserverTestsz'
    Tests for L{FileLogObserver}.
    �returnNc���t�5}t|d��}	tt|�ddd�y#t$r}|j|�Yd}~�(d}~wwxYw#1swYyxYw)z;
        L{FileLogObserver} is an L{ILogObserver}.
        c��t|�S�N��str��es �?/usr/lib/python3/dist-packages/twisted/logger/test/test_file.py�<lambda>z5FileLogObserverTests.test_interface.<locals>.<lambda>�
��S��V��N)rrrrr�fail)�self�
fileHandle�observerrs    r�test_interfacez#FileLogObserverTests.test_interfaces`���Z�	�:�&�z�3C�D�H�
��\�8�4�	�	��.�
��	�	�!����
��		�	�s+�A�3�	A�A�
A�A�A�A#c���t�5}t|d��}td��}||�|j|j	�t|��ddd�y#1swYyxYw)zV
        L{FileLogObserver} writes to the given file when it observes events.
        c��t|�Srrrs rrz9FileLogObserverTests.test_observeWrites.<locals>.<lambda>*rr ���xN)rr�dict�assertEqual�getvaluer�r"r#r$�events    r�test_observeWritesz'FileLogObserverTests.test_observeWrites%s^���Z�	@�:�&�z�3C�D�H��1�I�E��U�O����Z�0�0�2�C��J�?�		@�	@�	@�s�AA�A(�what�countc����t�5}tttt|��fd��}td��}||�|j
|j|�ddd�y#1swYyxYw)z�
        Verify that observer performs an expected number of writes when the
        formatter returns a given value.

        @param what: the value for the formatter to return.
        @param count: the expected number of writes.
        c����Sr�)rr1s �rrz:FileLogObserverTests._test_observeWrites.<locals>.<lambda>8s���D�r r(r)N)�	DummyFilerr
rrr+r,�writes)r"r1r2r#r$r/s `    r�_test_observeWritesz(FileLogObserverTests._test_observeWrites/s^����[�	7�J�&�t�B�s�G�Z�'@�.�Q�H��1�I�E��U�O����Z�.�.��6�		7�	7�	7�s�AA*�*A3c�(�|jdd�y)z�
        L{FileLogObserver} does not write to the given file when it observes
        events and C{formatEvent} returns L{None}.
        Nr�r8�r"s r�test_observeWritesNonez+FileLogObserverTests.test_observeWritesNone=s��
	
� � ��q�)r c�(�|jdd�y)z�
        L{FileLogObserver} does not write to the given file when it observes
        events and C{formatEvent} returns C{""}.
        �rNr:r;s r�test_observeWritesEmptyz,FileLogObserverTests.test_observeWritesEmptyDs��
	
� � ��Q�'r c���t�5}tttt|�d��}td��}||�|j
|jd�ddd�y#1swYyxYw)zl
        L{FileLogObserver} calles C{flush()} on the output file when it
        observes an event.
        c��t|�Srrrs rrz:FileLogObserverTests.test_observeFlushes.<locals>.<lambda>Qs��C�PQ�F�r r(r)N)r6rr
rrr+r,�flushesr.s    r�test_observeFlushesz(FileLogObserverTests.test_observeFlushesKs^��
�[�	4�J�&�t�B�s�G�Z�'@�BR�S�H��1�I�E��U�O����Z�/�/��3�		4�	4�	4�s�AA'�'A0�rN)
�__name__�
__module__�__qualname__�__doc__r%r0rr�intr8r<r?rCr5r rrrs?���	�@�7���
�7�c�7�d�7�*�(�	4r rc�8�eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zy)	�TextFileLogObserverTestsz+
    Tests for L{textFileLogObserver}.
    Nc��t�5}t|�}|j|t�ddd�y#1swYyxYw)zF
        L{textFileLogObserver} returns a L{FileLogObserver}.
        N)rr�assertIsInstancer�r"r#r$s   r�test_returnsFileLogObserverz4TextFileLogObserverTests.test_returnsFileLogObserver\s:���Z�	=�:�*�:�6�H��!�!�(�O�<�	=�	=�	=�s�"6�?c��t�5}t|�}|j|j|�ddd�y#1swYyxYw)�F
        Returned L{FileLogObserver} has the correct outFile.
        N)rr�assertIs�_outFilerNs   r�test_outFilez%TextFileLogObserverTests.test_outFileds>���Z�	9�:�*�:�6�H��M�M�(�+�+�Z�8�	9�	9�	9�s	�(<�Ac���t�5}t|d��}|tdd���|j|j	�d�ddd�y#1swYyxYw)rQz%f)�
timeFormat�XYZZYg�����m�@)�
log_format�log_timez600000 [-#-] XYZZY
N)rrr+r,r-rNs   r�test_timeFormatz(TextFileLogObserverTests.test_timeFormatlsY���Z�	L�:�*�:�$�G�H��T�W�x�@�A����Z�0�0�2�4J�K�	L�	L�	L�s�AA�Ac�X�t�5}t|�}	ddzt	��}||�|j�}|j
|jd�djd�t|���ddd�y#t$r
t�}Y�wxYw#1swYyxYw)z�
        If the C{"log_failure"} key exists in an event, the observer appends
        the failure's traceback to the output.
        r(r��log_failure�
z	Traceback )�msgN)
rr�ZeroDivisionErrorr
r+r-�
assertTrue�split�
startswith�repr)r"r#r$�failurer/�outputs      r�test_observeFailurez,TextFileLogObserverTests.test_observeFailureus���
�Z�
	�:�*�:�6�H�
$��A���W�-�E��U�O��(�(�*�F��O�O����T�"�1�%�0�0��@�d�6�l�
�
�
	�
	��
%�
$�!�)��
$��
	�
	�s.�B �B�A!B �B�B �B�B � B)c���t�5}t|�}tt���}||�|j	�}d}|j||�ddd�y#1swYyxYw)z�
        If the C{"log_failure"} key exists in an event, and contains an object
        that raises when you call its C{getTraceback()}, then the observer
        appends a message noting the problem, instead of raising.
        r\z'(UNABLE TO OBTAIN TRACEBACK FROM EVENT)N)rrr+�objectr-�assertIn)r"r#r$r/rf�expecteds      r�+test_observeFailureThatRaisesInGetTracebackzDTextFileLogObserverTests.test_observeFailureThatRaisesInGetTraceback�s^���Z�	,�:�*�:�6�H��V�X�.�E��U�O��(�(�*�F�@�H��M�M�(�F�+�
	,�	,�	,�s�AA � A)rD)	rErFrGrHrOrTrZrgrlr5r rrKrKWs!���=�9�L��(,r rKc	�n�eZdZdZd
d�Zdeddfd�Zd
d�Zdd�Zd	e	e
ed
e	ede	ede	e
fd�Zy)r6z.
    File that counts writes and flushes.
    rNc� �d|_d|_y)Nr)r7rBr;s r�__init__zDummyFile.__init__�s�������r �datac�.�|xjdz
c_y)z8
        Write data.

        @param data: data
        r(N)r7)r"rps  r�writezDummyFile.write�s��	
���q��r c�.�|xjdz
c_y)z 
        Flush buffers.
        r(N)rBr;s r�flushzDummyFile.flush�s��	
�����r c��|Srr5r;s r�	__enter__zDummyFile.__enter__�s���r �exc_type�	exc_value�	tracebackc��yrr5)r"rwrxrys    r�__exit__zDummyFile.__exit__�s��	
r rD)rr6)rErFrGrHrorrrrtrvrr	�
BaseExceptionr�boolr{r5r rr6r6�sl�����&��T����
��4�
�.�/�
��M�*�
��M�*�	
�

�$��
r r6N)rH�ior�typesr�typingrrrrr	r
�zope.interface.exceptionsr�zope.interface.verifyr�twisted.python.failurer
�twisted.trial.unittestr�_filerr�_interfacesrrrKr6r5r r�<module>r�sN�����8�8�@�.�*�+�8�&�?4�8�?4�D>,�x�>,�B 
� 
r 

Zerion Mini Shell 1.0