ó
    Ö›‘hÉ
  ã                   óz   • S r SSKJr  SSKJr  SSKJr  SSKJr   " S S\5      r	 " S S	\5      r
 " S
 S\5      rg)zA
Whitebox tests for L{twisted.internet.abstract.FileDescriptor}.
é    )ÚverifyClass)ÚFileDescriptor)ÚIPushProducer)ÚSynchronousTestCasec                   ó4   • \ rS rSrSrSrS rS rS rS r	Sr
g	)
Ú
MemoryFileé   a  
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                 óZ   • [         R                  " U [        5       S9  / U l        SU l        g )N©Úreactorr   )r   Ú__init__ÚobjectÚ_writtenÚ
_freeSpace©Úselfs    ÚmC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_filedescriptor.pyr   ÚMemoryFile.__init__   s"   € Ü×Ò ¬f«hÒ7ØˆŒØˆ�ó    c                 ó   • g ©N© r   s    r   ÚstartWritingÚMemoryFile.startWriting"   ó   € Ør   c                 ó   • g r   r   r   s    r   ÚstopWritingÚMemoryFile.stopWriting%   r   r   c                 ó¸   • [        U R                  [        U5      5      nU(       a3  U =R                  U-  sl        U R                  R	                  USU 5        U$ )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   ÚwriteSomeDataÚMemoryFile.writeSomeData(   sH   € ô ˜4Ÿ?™?¬C°«IÓ6ˆÞØ�OŠO˜|Ñ+�OØ�M‰M× Ñ   m |Ð!4Ô5ØÐr   )r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	connectedr   r   r   r%   Ú__static_attributes__r   r   r   r   r      s"   † ñð €Iòò
òõ
r   r   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚFileDescriptorTestsé5   z
Tests for L{FileDescriptor}.
c                 óh   • [        [        5       S9nU R                  [        UR                  S5        g)z6
L{FileDescriptor.write} doesn't accept unicode data.
r   ÚfooN)r   r   ÚassertRaisesÚ	TypeErrorÚwrite©r   ÚfileDescriptors     r   Ú$test_writeWithUnicodeRaisesExceptionÚ8FileDescriptorTests.test_writeWithUnicodeRaisesException:   s(   € ô (´³Ñ9ˆØ×Ñœ) ^×%9Ñ%9¸5ÕAr   c                 ól   • [        [        5       S9nU R                  [        UR                  / SQ5        g)z>
L{FileDescriptor.writeSequence} doesn't accept unicode data.
r   )s   fooÚbars   bazN)r   r   r3   r4   ÚwriteSequencer6   s     r   Ú,test_writeSequenceWithUnicodeRaisesExceptionÚ@FileDescriptorTests.test_writeSequenceWithUnicodeRaisesExceptionA   s,   € ô (´³Ñ9ˆØ×ÑÜ�~×3Ñ3Ò5Lõ	
r   c                 óJ   • U R                  [        [        [        5      5        g)z6
L{FileDescriptor} should implement L{IPushProducer}.
N)Ú
assertTruer   r   r   r   s    r   Ú$test_implementInterfaceIPushProducerÚ8FileDescriptorTests.test_implementInterfaceIPushProducerJ   s   € ð 	�‰œ¤M´>ÓBÕCr   r   N)	r'   r(   r)   r*   r+   r8   r=   rA   r-   r   r   r   r/   r/   5   s   † ñòBò
õDr   r/   c                   ó   • \ rS rSrSrS rSrg)ÚWriteDescriptorTestséQ   zF
Tests for L{FileDescriptor}'s implementation of L{IWriteDescriptor}.
c                 óx   • [        5       nUR                  S5        U R                  UR                  5       5        g)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   r5   ÚassertIsNoneÚdoWrite)r   Ú
descriptors     r   Útest_kernelBufferFullÚ*WriteDescriptorTests.test_kernelBufferFullV   s0   € ô  “\ˆ
Ø×Ñ˜Ô)Ø×Ñ˜*×,Ñ,Ó.Õ/r   r   N)r'   r(   r)   r*   r+   rJ   r-   r   r   r   rD   rD   Q   s   † ñõ0r   rD   N)r+   Úzope.interface.verifyr   Útwisted.internet.abstractr   Útwisted.internet.interfacesr   Útwisted.trial.unittestr   r   r/   rD   r   r   r   Ú<module>rP      sA   ðñõ
 .å 4Ý 5Ý 6ô"�ô "ôJDÐ-ô Dô80Ð.õ 0r   