+
    Dfj
                     |    R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt  ! R R]4      t	 ! R R]4      t
 ! R	 R
]4      tR# )zA
Whitebox tests for L{twisted.internet.abstract.FileDescriptor}.
)verifyClass)FileDescriptor)IPushProducer)SynchronousTestCasec                   @   a  ] tR t^t o RtRtR tR tR tR t	Rt
V tR# )	
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                b    \         P                  ! V \        4       R 7       . V n        ^ V n        R# )reactorN)r   __init__object_written
_freeSpaceselfs   &K/usr/lib/python3/dist-packages/twisted/internet/test/test_filedescriptor.pyr   MemoryFile.__init__   s"    fh7    c                    R # N r   s   &r   startWritingMemoryFile.startWriting"       r   c                    R # r   r   r   s   &r   stopWritingMemoryFile.stopWriting%   r   r   c                    \        V P                  \        V4      4      pV'       d8   V ;P                  V,          un        V P                  P	                  VRV 4       V# )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OO|+OMM  m|!45r   )r   r   N)__name__
__module____qualname____firstlineno____doc__	connectedr   r   r   r#   __static_attributes____classdictcell____classdict__s   @r   r   r      s*      I

 
r   r   c                   6   a  ] tR t^5t o RtR tR tR tRtV t	R# )FileDescriptorTestsz
Tests for L{FileDescriptor}.
c                p    \        \        4       R7      pV P                  \        VP                  R4       R# )z6
L{FileDescriptor.write} doesn't accept unicode data.
r	   fooN)r   r   assertRaises	TypeErrorwriter   fileDescriptors   & r   $test_writeWithUnicodeRaisesException8FileDescriptorTests.test_writeWithUnicodeRaisesException:   s(     (9)^%9%95Ar   c                t    \        \        4       R7      pV P                  \        VP                  . RO4       R# )z>
L{FileDescriptor.writeSequence} doesn't accept unicode data.
r	   N)s   foobars   baz)r   r   r3   r4   writeSequencer6   s   & r   ,test_writeSequenceWithUnicodeRaisesException@FileDescriptorTests.test_writeSequenceWithUnicodeRaisesExceptionA   s,     (9~335L	
r   c                L    V P                  \        \        \        4      4       R# )z6
L{FileDescriptor} should implement L{IPushProducer}.
N)
assertTruer   r   r   r   s   &r   $test_implementInterfaceIPushProducer8FileDescriptorTests.test_implementInterfaceIPushProducerJ   s     	M>BCr   r   N)
r%   r&   r'   r(   r)   r8   r=   rA   r+   r,   r-   s   @r   r0   r0   5   s!     B
D Dr   r0   c                   *   a  ] tR t^Qt o RtR tRtV tR# )WriteDescriptorTestszF
Tests for L{FileDescriptor}'s implementation of L{IWriteDescriptor}.
c                z    \        4       pVP                  R4       V P                  VP                  4       4       R# )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)   rI   r+   r,   r-   s   @r   rD   rD   Q   s     0 0r   rD   N)r)   zope.interface.verifyr   twisted.internet.abstractr   twisted.internet.interfacesr   twisted.trial.unittestr   r   r0   rD   r   r   r   <module>rO      sA   
 . 4 5 6" "JD- D80. 0r   