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

�

Ϫ�f�"����dZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
dd	lmZdd
lmZddlmZddlmZee�Gd
�de��ZGd�de
j.�Zy)z'
Test cases for L{twisted.logger._io}.
�N)�List�Optional)�implementer)�
NamedConstant)�unittest�)�ILogObserver�LogEvent)�LoggingFile)�LogLevel)�Logger)�LogPublisherc	�d��eZdZdZej
dfdededee	ddf�fd�
Z
deddfd	�Z�xZ
S)
�TestLoggingFilezU
    L{LoggingFile} that is also an observer which captures events and messages.
    N�logger�level�encoding�returnc�F��t�|�|||��g|_g|_y)N�rrr)�super�__init__�events�messages)�selfrrr�	__class__s    ��=/usr/lib/python3/dist-packages/twisted/logger/test/test_io.pyrzTestLoggingFile.__init__s'���	����e�h��G�&(���#%��
��eventc��|jj|�d|vr|jj|d�yy)N�log_io)r�appendr)rrs  r�__call__zTestLoggingFile.__call__'s7�������5�!��u���M�M� � ��x��1�r)�__name__�
__module__�__qualname__�__doc__r�infor
rr�strrr
r#�
__classcell__)rs@rrrsV���� (�}�}�"&�	&��&��&��3�-�	&�

�&�2�h�2�4�2rrc���eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd	�Z	dd
�Z
dd�Zdd�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zej2dfdedeedefd�Zy)�LoggingFileTestsz#
    Tests for L{LoggingFile}.
    rNc�X�t�|_t|j��|_y)zK
        Create a logger for test L{LoggingFile} instances to use.
        ��observerN)r�	publisherr
r)rs r�setUpzLoggingFileTests.setUp2s��&�����d�n�n�5��rc�B�|jt|j�jd�|j	|j
g�}|jt
|�d�|j|ddt�d}|j|ddd|z�y)z0
        L{LoggingFile.softspace} is 0.
        r��categoryz(twisted.logger._io.LoggingFile.softspace�messagez#%s was deprecated in Twisted 21.2.0N)�assertEqualrr�	softspace�
flushWarnings�test_softspace�len�DeprecationWarning)r�
warningsShown�deprecatedClasss   rr9zLoggingFileTests.test_softspace9s���	
����T�[�[�1�;�;�Q�?��*�*�D�,?�,?�+@�A�
�����]�+�Q�/�����q�)�*�5�7I�J�D������!��Y�'�1�_�E�	
rc�R�t|j�}|jtt|dd�|jtt|dd�|jtt|dd�|jtt|ddg�|jtt|d	d
�y)z?
        Some L{LoggingFile} attributes are read-only.
        �closedTr�utf-8�mode�r�newlines�
�name�fooN)rr�assertRaises�AttributeError�setattr�r�fs  r�test_readOnlyAttributesz(LoggingFileTests.test_readOnlyAttributesHs���
����$�����.�'�1�h��E����.�'�1�j�'�J����.�'�1�f�c�B����.�'�1�j�4�&�I����.�'�1�f�e�Drc�.�t|j�}|jt|j�|jt|j
�|jt|j�|jt|j�|jt|j�|jt|j�|jt|j�|jt|j�y)z>
        Some L{LoggingFile} methods are unsupported.
        N)rrrG�IOError�read�next�readline�	readlines�
xreadlines�seek�tell�truncaterJs  r�test_unsupportedMethodsz(LoggingFileTests.test_unsupportedMethodsTs���
����$�����'�1�6�6�*����'�1�6�6�*����'�1�:�:�.����'�1�;�;�/����'�1�<�<�0����'�1�6�6�*����'�1�6�6�*����'�1�:�:�.rc� �t|j�}|j|jtj
�t|jtj��}|j|jtj�y)z?
        Default level is L{LogLevel.info} if not set.
        �rN)rrr6rrr(�errorrJs  r�
test_levelzLoggingFileTests.test_levelcsV��
����$��������(�-�-�0�����8�>�>�:��������(�.�.�1rc���t|j�}|j|jt	j
��t|jd��}|j|jd�y)zM
        Default encoding is C{sys.getdefaultencoding()} if not set.
        r@�rN)rrr6r�sys�getdefaultencodingrJs  r�
test_encodingzLoggingFileTests.test_encodingmsS��
����$��������S�%;�%;�%=�>�����g�6��������W�-rc�f�t|j�}|j|jd�y)z*
        Reported mode is C{"w"}.
        �wN)rrr6rArJs  r�	test_modezLoggingFileTests.test_modews&��
����$���������%rc�d�t|j�}|j|j�y)z7
        The C{newlines} attribute is L{None}.
        N)rr�assertIsNonerCrJs  r�
test_newlineszLoggingFileTests.test_newlines~s$��
����$�����!�*�*�%rc�f�t|j�}|j|jd�y)z1
        The C{name} attribute is fixed.
        z.<LoggingFile twisted.logger.test.test_io#info>N)rrr6rErJs  r�	test_namezLoggingFileTests.test_name�s'��
����$��������!Q�Rrc���t|j�}|j�|j|j�|jt|jd�y)z7
        L{LoggingFile.close} closes the file.
        �HelloN)rr�close�
assertTruer?rG�
ValueError�writerJs  r�
test_closezLoggingFileTests.test_close�sA��
����$��	���	�������!����*�a�g�g�w�7rc�N�t|j�}|j�y)z4
        L{LoggingFile.flush} does nothing.
        N)rr�flushrJs  r�
test_flushzLoggingFileTests.test_flush�s��
����$��	���	rc�n�t|j�}|j|j�d�y)z6
        L{LoggingFile.fileno} returns C{-1}.
        ���N)rrr6�filenorJs  r�test_filenozLoggingFileTests.test_fileno�s(��
����$���������R�(rc�l�t|j�}|j|j��y)z9
        L{LoggingFile.isatty} returns C{False}.
        N)rr�assertFalse�isattyrJs  r�test_isattyzLoggingFileTests.test_isatty�s&��
����$���������$rc�8�|j�}|jd�|j|jg�|jd�|j|jdg�|jd�|j|jgd��y)z,
        Writing buffers correctly.
        rjz	, world!
�
Hello, world!zIt's nice to meet you.

Indeed.�r|zIt's nice to meet you.�N��observedFilernr6rrJs  r�test_writeBufferingz$LoggingFileTests.test_writeBuffering�s|��
�����	�����������R�(�	�����������o�%6�7�	���3�4����
�J�J�
�	
rc��|jd��}|jd�|j|jdg�y)z,
        Bytes are decoded to text.
        r@r]sHello, Mr. Sánchez
�Hello, Mr. SánchezNrrJs  r�test_writeBytesDecodedz'LoggingFileTests.test_writeBytesDecoded�s<��
���w��/��	���.�/�������&=�%>�?rc��|jd��}|jd�|j|jdg�y)z(
        Unicode is unmodified.
        r@r]uHello, Mr. Sánchez
r�NrrJs  r�test_writeUnicodez"LoggingFileTests.test_writeUnicode�s<��
���w��/��	���)�*�������&=�%>�?rc��|j�}|jd�|jt|j�d�|j|jddt
j�|jt
j��}|jd�|jt|j�d�|j|jddt
j�y)z0
        Log level is emitted properly.
        �Hello
r3r�	log_levelrYN)r�rnr6r:rrr(rZrJs  r�test_writeLevelz LoggingFileTests.test_writeLevel�s���
�����	���	������Q�X�X���*�������!��[�1�8�=�=�A����H�N�N��3��	���	������Q�X�X���*�������!��[�1�8�>�>�Brc���|j�}|jd�|jt|j�d�|j|jddd�y)z/
        Log format is C{"{message}"}.
        r�r3r�
log_formatz{log_io}N)r�rnr6r:rrJs  r�test_writeFormatz!LoggingFileTests.test_writeFormat�sS��
�����	���	������Q�X�X���*�������!��\�2�J�?rc�8�|j�}|jd�|j|jg�|jd�|j|jdg�|jd�|j|jgd��y)z6
        C{writelines} does not add newlines.
        )rjz, r~)zworld!
r|)zIt's nice to meet you.

zIndeed.r}N)r��
writelinesr6rrJs  r�test_writelinesBufferingz)LoggingFileTests.test_writelinesBuffering�s}��

�����	���(�)�������R�(�	���]�#�������o�%6�7�	���>�?����
�J�J�
�	
rc��|j�}|jtd|�tdd��td�|j	|j
dg�y)z;
        L{LoggingFile} can replace L{sys.stdout}.
        �stdoutzHello,� )�endzworld.z
Hello, world.N)r��patchr^�printr6rrJs  r�
test_printzLoggingFileTests.test_print�sJ��
������
�
�3��!�$�
�h�C� �
�h��������o�%6�7rrrc���g�tt�dtddf�fd��}t|��}�j	t|||����dS)a�
        Construct a L{LoggingFile} with a built-in observer.

        @param level: C{level} argument to L{LoggingFile}
        @param encoding: C{encoding} argument to L{LoggingFile}

        @return: a L{TestLoggingFile} with an observer that appends received
            events into the file's C{events} attribute (a L{list}) and
            event messages into the file's C{messages} attribute (a L{list}).
        rrNc����d|�y)Nr�)r�loggingFiless �rr/z/LoggingFileTests.observedFile.<locals>.observers����L��O�E�"rr.rr)rr	r
r
r"r)rrrr/�logr�s     @rr�zLoggingFileTests.observedFiles\���&/1��	�\�	"�	#�H�	#��	#�
#�	#��h�'�����O�3�e�h�W�X��A��r)rN)r$r%r&r'r1r9rLrWr[r`rcrfrhrorrrvrzr�r�r�r�r�r�r�rr(rrr)rr�r�rrr,r,-s����6�

�
E�
/�2�.�&�&�S�8��)�%�
�&@�@�C�@�
�(
8� (�}�}�"&�����3�-��
�	rr,)r'r^�typingrr�zope.interfacer�
constantlyr�
twisted.trialr�_interfacesr	r
�_ior�_levelsr�_loggerr
�	_observerrr�TestCaser,r�rr�<module>r�s^����!�&�$�"�0����$�
�\��2�k�2��2�*t�x�(�(�tr

Zerion Mini Shell 1.0