HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_filedescriptor.cpython-38.pyc
U


W[�
�@sxdZddlmZmZddlmZddlmZddlm	Z	ddl
mZGdd�de�ZGd	d
�d
e�Z
Gdd�de�Zd
S)zA
Whitebox tests for L{twisted.internet.abstract.FileDescriptor}.
�)�division�absolute_import)�verifyClass)�FileDescriptor)�
IPushProducer)�SynchronousTestCasec@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�
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.
    TcCs tj|t�d�g|_d|_dS)N�Zreactorr)r�__init__�object�_written�
_freeSpace��self�r�K/usr/lib/python3/dist-packages/twisted/internet/test/test_filedescriptor.pyr
szMemoryFile.__init__cCsdS�Nrrrrr�startWriting$szMemoryFile.startWritingcCsdSrrrrrr�stopWriting(szMemoryFile.stopWritingcCs:t|jt|��}|r6|j|8_|j�|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�dataZacceptLengthrrr�
writeSomeData,s
zMemoryFile.writeSomeDataN)	�__name__�
__module__�__qualname__�__doc__Z	connectedr
rrrrrrrrs	rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FileDescriptorTestsz&
    Tests for L{FileDescriptor}.
    cCs tt�d�}|�t|jd�dS)zF
        L{FileDescriptor.write} doesn't accept unicode data.
        r	ZfooN)rr�assertRaises�	TypeError�write�rZfileDescriptorrrr�$test_writeWithUnicodeRaisesException>sz8FileDescriptorTests.test_writeWithUnicodeRaisesExceptioncCs&tt�d�}|�t|jdddg�dS)zN
        L{FileDescriptor.writeSequence} doesn't accept unicode data.
        r	sfooZbarsbazN)rrrr Z
writeSequencer"rrr�,test_writeSequenceWithUnicodeRaisesExceptionFs�z@FileDescriptorTests.test_writeSequenceWithUnicodeRaisesExceptioncCs|�ttt��dS)zF
        L{FileDescriptor} should implement L{IPushProducer}.
        N)Z
assertTruerrrrrrr�$test_implementInterfaceIPushProducerOsz8FileDescriptorTests.test_implementInterfaceIPushProducerN)rrrrr#r$r%rrrrr:s	rc@seZdZdZdd�ZdS)�WriteDescriptorTestszN
    Tests for L{FileDescriptor}'s implementation of L{IWriteDescriptor}.
    cCs"t�}|�d�|�|���dS)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!ZassertIsNoneZdoWrite)rZ
descriptorrrr�test_kernelBufferFull[s
z*WriteDescriptorTests.test_kernelBufferFullN)rrrrr'rrrrr&Wsr&N)rZ
__future__rrZzope.interface.verifyrZtwisted.internet.abstractrZtwisted.internet.interfacesrZtwisted.trial.unittestrrrr&rrrr�<module>s(