%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�
��z�dZddlmZddlmZddlmZddlmZGd�de�Z	Gd�d	e�Z
Gd
�de�Zy)
zA
Whitebox tests for L{twisted.internet.abstract.FileDescriptor}.
�)�verifyClass)�FileDescriptor)�
IPushProducer)�SynchronousTestCasec�,�eZdZdZdZd�Zd�Zd�Zd�Zy)�
MemoryFilea-
    A L{FileDescriptor} customization which writes to a Python list in memory
    with certain limitations.

    @ivar _written: A C{list} of C{bytes} which have been accepted as written.

    @ivar _freeSpace: A C{int} giving the number of bytes which will be accepted
        by future writes.
    Tc�^�tj|t���g|_d|_y)N��reactorr)r�__init__�object�_written�
_freeSpace��selfs �K/usr/lib/python3/dist-packages/twisted/internet/test/test_filedescriptor.pyrzMemoryFile.__init__s"������f�h�7���
����c��y�N�rs r�startWritingzMemoryFile.startWriting"���rc��yrrrs r�stopWritingzMemoryFile.stopWriting%rrc��t|jt|��}|r3|xj|zc_|jj	|d|�|S)z�
        Copy at most C{self._freeSpace} bytes from C{data} into C{self._written}.

        @return: A C{int} indicating how many bytes were copied from C{data}.
        N)�minr�lenr�append)r�data�acceptLengths   r�
writeSomeDatazMemoryFile.writeSomeData(sH���4�?�?�C��I�6����O�O�|�+�O��M�M� � ��m�|�!4�5��rN)	�__name__�
__module__�__qualname__�__doc__�	connectedrrrr!rrrrrs"����I��

�
�
rrc�"�eZdZdZd�Zd�Zd�Zy)�FileDescriptorTestsz&
    Tests for L{FileDescriptor}.
    c�n�tt���}|jt|jd�y)zF
        L{FileDescriptor.write} doesn't accept unicode data.
        r
�fooN)rr
�assertRaises�	TypeError�write�r�fileDescriptors  r�$test_writeWithUnicodeRaisesExceptionz8FileDescriptorTests.test_writeWithUnicodeRaisesException:s(��(���9�����)�^�%9�%9�5�Arc�r�tt���}|jt|jgd��y)zN
        L{FileDescriptor.writeSequence} doesn't accept unicode data.
        r
)sfoo�barsbazN)rr
r+r,�
writeSequencer.s  r�,test_writeSequenceWithUnicodeRaisesExceptionz@FileDescriptorTests.test_writeSequenceWithUnicodeRaisesExceptionAs,��(���9������~�3�3�5L�	
rc�J�|jttt��y)zF
        L{FileDescriptor} should implement L{IPushProducer}.
        N)�
assertTruerrrrs r�$test_implementInterfaceIPushProducerz8FileDescriptorTests.test_implementInterfaceIPushProducerJs��	
����M�>�B�CrN)r"r#r$r%r0r4r7rrrr(r(5s���B�
�Drr(c��eZdZdZd�Zy)�WriteDescriptorTestszN
    Tests for L{FileDescriptor}'s implementation of L{IWriteDescriptor}.
    c�x�t�}|jd�|j|j��y)z�
        When L{FileDescriptor.writeSomeData} returns C{0} to indicate no more
        data can be written immediately, L{FileDescriptor.doWrite} returns
        L{None}.
        shello, worldN)rr-�assertIsNone�doWrite)r�
descriptors  r�test_kernelBufferFullz*WriteDescriptorTests.test_kernelBufferFullVs0�� �\�
�����)����*�,�,�.�/rN)r"r#r$r%r>rrrr9r9Qs���0rr9N)r%�zope.interface.verifyr�twisted.internet.abstractr�twisted.internet.interfacesr�twisted.trial.unittestrrr(r9rrr�<module>rCsA���
.�4�5�6�"��"�JD�-�D�8
0�.�
0r

Zerion Mini Shell 1.0