+
    Dfj                         R t ^ RIHt ^ RIHt ^ RIHt ]P                  ! 4       '       g   ^ RIH	t	  ! R R]4      t
]! 4       P                  ]
P                  4       4       R# )z&
Tests for L{twisted.internet.stdio}.
)Protocol)ReactorBuilder)platform)
StandardIOc                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 t]P                  ! 4       '       d	   R
tRtV tR# RtV tR# )StdioFilesTestszA
L{StandardIO} supports reading and writing to filesystem files.
c                    V P                  4       p\        VR 4      P                  4        \        VR4      V n        V P	                  V P                  P                  4       R# )wbzrb+N)mktempopenclose	extraFile
addCleanup)selfpaths   & B/usr/lib/python3/dist-packages/twisted/internet/test/test_stdio.pysetUpStdioFilesTests.setUp   sD    {{}T4 dE*,,-    c           	        a V P                  4       o ! V3R lR\        4      pV P                  4       p\        VR4      ;_uu_ 4       pVP	                  R4       RRR4       \        VR4      ;_uu_ 4       pV! 4       p\        VVP                  4       V P                  P                  4       SR7       V P                  S4       RRR4       V P                  XP                  R4       R#   + '       g   i     L; i  + '       g   i     LA; i)zK
Adding a filesystem file reader to a reactor will make sure it is
polled.
c                   2   <a  ] tR t^#t o RtV3R ltRtV tR# )4StdioFilesTests.test_addReader.<locals>.DataProtocolr   c                   < V ;P                   V,          un         V P                   R 8X  d   SP                  4        R# R# )   hello!N)datastop)r   r   reactors   &&r   dataReceivedAStdioFilesTests.test_addReader.<locals>.DataProtocol.dataReceived&   s-    		T!	 99	)LLN *r    N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__r   s   @r   DataProtocolr   #   s     D# #r   r(   r	   r   Nrbstdinstdoutr   )buildReactorr   r
   r   writer   filenor   
runReactorassertEqualr   )r   r(   r   fprotocolr   s   &    @r   test_addReaderStdioFilesTests.test_addReader   s    
 ##%		#8 		# {{}$GGI  $#~Hhhj~~,,.	 OOG$  		2  s   C*6AC=*C:	=D	c           	       a V P                  4       o ! V3R lR\        4      pV P                  4       p\        VR4      ;_uu_ 4       pV! 4       p\	        VVP                  4       V P                  P                  4       SR7       VP                  P                  R4       VP                  P                  R4       VP                  P                  4        V P                  S4       RRR4       \        VR4      ;_uu_ 4       pV P                  VP                  4       R	4       RRR4       R#   + '       g   i     LO; i  + '       g   i     R# ; i)
zK
Adding a filesystem file writer to a reactor will make sure it is
polled.
c                   .   <a  ] tR t^Gt o V3R ltRtV tR# ):StdioFilesTests.test_addWriter.<locals>.DisconnectProtocolc                (   < SP                  4        R # )N)r   )r   reasonr   s   &&r   connectionLostIStdioFilesTests.test_addWriter.<locals>.DisconnectProtocol.connectionLostH   s    r   r   N)r    r!   r"   r#   r;   r$   r%   r&   s   @r   DisconnectProtocolr8   G   s      r   r=   r	   r,   r+   r      hellos   , worldNr)   s   hello, world)r-   r   r
   r   r   r/   r   	transportr.   loseConnectionr0   r1   read)r   r=   r   r2   r3   r   s   &    @r   test_addWriterStdioFilesTests.test_addWriter@   s    
 ##%	 	 {{}$ *+Hxxznn++-	 $$X.$$Z0--/OOG$   $QVVX7 !   s   BD-!E -D=	 E	c           	     2   V P                  4       pV P                  4       p\        VR4      P                  4        \        VR4      ;_uu_ 4       p\	        \        4       VP                  4       V P                  P                  4       VR7      pV P                  VP                  VP                  4       4       VP                  P                  4        V P                  VP                  VP                  4       4       RRR4       R#   + '       g   i     R# ; i)zY
Removing a filesystem file reader from a reactor will make sure it is
no longer polled.
r	   r)   r*   N)r-   r
   r   r   r   r   r/   r   assertIn_reader
getReadersstopReadingassertNotInr   r   r   r2   stdios   &    r   test_removeReader!StdioFilesTests.test_removeReader`   s    
 ##%{{}T4 $
hhj~~,,.	E MM%--););)=>MM%%'U]]G,>,>,@A s   B,DD	c                   V P                  4       p\        V P                  4       R4      ;V n        p\	        4       p\        W2P                  4       V P                  P                  4       VR7      pVP                  P                  R4       V P                  VP                  VP                  4       4       VP                  P                  4        V P                  VP                  VP                  4       4       R# )zY
Removing a filesystem file writer from a reactor will make sure it is
no longer polled.
r	   r>   r?   N)r-   r   r
   r2   r   r   r/   r   r@   r.   rF   _writer
getWritersstopWritingrJ   )r   r   r2   r3   rL   s   &    r   test_removeWriter!StdioFilesTests.test_removeWriterv   s    
 ##% $++-.. :XXZt~~/D/D/FPW
 	  *emmW%7%7%9:!!#(:(:(<=r   c                   V P                  4       pV P                  4       p\        VR4      P                  4        \        VR4      ;V n        p\        \        4       VP                  4       V P                  P                  4       VR7      pVP                  4       pV P                  VP                  V4       V P                  VP                  VP                  4       4       R# )zS
Calling C{removeAll} on a reactor includes descriptors that are
filesystem files.
r	   r)   r*   N)r-   r
   r   r   r2   r   r   r/   r   	removeAllrF   rG   rJ   rH   )r   r   r   r2   rL   removeds   &     r   test_removeAllStdioFilesTests.test_removeAll   s    
 ##%{{}T4  $%% J((*>>((*	
 ##%emmW-(:(:(<=r   c           	        V P                  4       pV P                  4       p\        VR4      P                  4        \        VR4      ;_uu_ 4       p\	        \        4       VP                  4       V P                  P                  4       VR7      pV P                  VP                  VP                  4       4       RRR4       R#   + '       g   i     R# ; i)zG
C{reactor.getReaders} includes descriptors that are filesystem files.
r	   r)   r*   N)r-   r
   r   r   r   r   r/   r   rF   rG   rH   rK   s   &    r   test_getReadersStdioFilesTests.test_getReaders   s     ##%{{}T4  $
hhj~~,,.	E MM%--););)=> s   A(CC	c                   V P                  4       p\        V P                  4       R4      ;V n        p\	        \        4       VP                  4       V P                  P                  4       VR7      pV P                  VP                  VP                  4       4       VP                  P                  4        V P                  VP                  VP                  4       4       R# )zG
C{reactor.getWriters} includes descriptors that are filesystem files.
r	   r>   N)r-   r   r
   r2   r   r   r/   r   rJ   rP   rQ   startWritingrF   )r   r   r2   rL   s   &   r   test_getWritersStdioFilesTests.test_getWriters   s     ##% $++-.. J88:..'')	
 	(:(:(<=""$emmW%7%7%9:r   zoStandardIO does not accept stdout as an argument to Windows. Testing redirection to a file is therefore harder.)r   r2   N)r    r!   r"   r#   __doc__r   r4   rC   rM   rS   rX   r[   r_   r   	isWindowsskipr$   r%   )r'   s   @r   r   r      sV     ."3H8@B,>(>2?(;( A 	 r   r   N)ra   twisted.internet.protocolr   #twisted.internet.test.reactormixinsr   twisted.python.runtimer   rb   twisted.internet.stdior   r   globalsupdatemakeTestCaseClassesr   r   r   <module>rk      sQ   
 / > +1~
n ~
B 	  446 7r   