§
    ÈtºfÉ
  ã                   óŽ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d„ de¦  «        Z	 G d„ d	e¦  «        Z
 G d
„ de¦  «        ZdS )zA
Whitebox tests for L{twisted.internet.abstract.FileDescriptor}.
é    )ÚverifyClass)ÚFileDescriptor)ÚIPushProducer)ÚSynchronousTestCasec                   ó.   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ ZdS )Ú
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                 óf   — t          j        | t          ¦   «         ¬¦  «         g | _        d| _        d S )N©Úreactorr   )r   Ú__init__ÚobjectÚ_writtenÚ
_freeSpace©Úselfs    úh/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/test/test_filedescriptor.pyr   zMemoryFile.__init__   s.   € ÝÔ ­f©h¬hÐ7Ñ7Ô7Ð7ØˆŒØˆŒˆˆó    c                 ó   — d S ©N© r   s    r   ÚstartWritingzMemoryFile.startWriting"   ó   € Øˆr   c                 ó   — d S r   r   r   s    r   ÚstopWritingzMemoryFile.stopWriting%   r   r   c                 ó²   — t          | j        t          |¦  «        ¦  «        }|r2| xj        |z  c_        | 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   ÚdataÚacceptLengths      r   ÚwriteSomeDatazMemoryFile.writeSomeData(   sX   € õ ˜4œ?­C°©I¬IÑ6Ô6ˆØð 	6ØˆOŒO˜|Ñ+ˆOŒOØŒM× Ò   m | mÔ!4Ñ5Ô5Ð5ØÐr   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	connectedr   r   r   r!   r   r   r   r   r      sa   € € € € € ðð ð €Iðð ð ð
ð ð ðð ð ð
ð 
ð 
ð 
ð 
r   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚFileDescriptorTestsz&
    Tests for L{FileDescriptor}.
    c                 ó€   — t          t          ¦   «         ¬¦  «        }|                      t          |j        d¦  «         dS )zF
        L{FileDescriptor.write} doesn't accept unicode data.
        r
   ÚfooN)r   r   ÚassertRaisesÚ	TypeErrorÚwrite©r   ÚfileDescriptors     r   Ú$test_writeWithUnicodeRaisesExceptionz8FileDescriptorTests.test_writeWithUnicodeRaisesException:   s9   € õ (µ±´Ð9Ñ9Ô9ˆØ×Ò�) ^Ô%9¸5ÑAÔAÐAÐAÐAr   c                 ó„   — t          t          ¦   «         ¬¦  «        }|                      t          |j        g d¢¦  «         dS )zN
        L{FileDescriptor.writeSequence} doesn't accept unicode data.
        r
   )s   fooÚbars   bazN)r   r   r+   r,   ÚwriteSequencer.   s     r   Ú,test_writeSequenceWithUnicodeRaisesExceptionz@FileDescriptorTests.test_writeSequenceWithUnicodeRaisesExceptionA   sK   € õ (µ±´Ð9Ñ9Ô9ˆØ×ÒÝ�~Ô3Ð5LÐ5LÐ5Lñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó`   — |                       t          t          t          ¦  «        ¦  «         dS )zF
        L{FileDescriptor} should implement L{IPushProducer}.
        N)Ú
assertTruer   r   r   r   s    r   Ú$test_implementInterfaceIPushProducerz8FileDescriptorTests.test_implementInterfaceIPushProducerJ   s&   € ð 	�Š�¥Mµ>ÑBÔBÑCÔCÐCÐCÐCr   N)r"   r#   r$   r%   r0   r4   r7   r   r   r   r(   r(   5   sS   € € € € € ðð ðBð Bð Bð
ð 
ð 
ðDð Dð Dð Dð Dr   r(   c                   ó   — e Zd ZdZd„ ZdS )ÚWriteDescriptorTestszN
    Tests for L{FileDescriptor}'s implementation of L{IWriteDescriptor}.
    c                 óš   — t          ¦   «         }|                     d¦  «         |                      |                     ¦   «         ¦  «         dS )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)r   r-   ÚassertIsNoneÚdoWrite)r   Ú
descriptors     r   Útest_kernelBufferFullz*WriteDescriptorTests.test_kernelBufferFullV   sG   € õ  ‘\”\ˆ
Ø×Ò˜Ñ)Ô)Ð)Ø×Ò˜*×,Ò,Ñ.Ô.Ñ/Ô/Ð/Ð/Ð/r   N)r"   r#   r$   r%   r>   r   r   r   r9   r9   Q   s-   € € € € € ðð ð0ð 0ð 0ð 0ð 0r   r9   N)r%   Úzope.interface.verifyr   Útwisted.internet.abstractr   Útwisted.internet.interfacesr   Útwisted.trial.unittestr   r   r(   r9   r   r   r   ú<module>rC      sì   ððð ð
 .Ð -Ð -Ð -Ð -Ð -à 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6ð"ð "ð "ð "ð "�ñ "ô "ð "ðJDð Dð Dð Dð DÐ-ñ Dô Dð Dð80ð 0ð 0ð 0ð 0Ð.ñ 0ô 0ð 0ð 0ð 0r   