ó
    Ö›‘h·  ã                   óÂ   • S r SSKJr  SSKJr  SSKJr  \R                  " 5       (       d  SSKJ	r	   " S S\5      r
\" 5       R                  \
R                  5       5        g)	z&
Tests for L{twisted.internet.stdio}.
é    )ÚProtocol)ÚReactorBuilder)Úplatform)Ú
StandardIOc                   ó~   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 r\R                  " 5       (       a  SrSrgSrg)ÚStdioFilesTestsé   zA
L{StandardIO} supports reading and writing to filesystem files.
c                 óÄ   • U R                  5       n[        US5      R                  5         [        US5      U l        U R	                  U R                  R                  5        g )NÚwbzrb+)ÚmktempÚopenÚcloseÚ	extraFileÚ
addCleanup)ÚselfÚpaths     ÚdC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_stdio.pyÚsetUpÚStdioFilesTests.setUp   sD   € Ø�{‰{‹}ˆÜˆT�4Ó×ÑÔ Ü˜d EÓ*ˆŒØ�‰˜Ÿ™×,Ñ,Õ-ó    c                 óð  ^• U R                  5       m " U4S jS[        5      nU R                  5       n[        US5       nUR	                  S5        SSS5        [        US5       nU" 5       n[        UUR                  5       U R                  R                  5       TS9  U R                  T5        SSS5        U R                  WR                  S5        g! , (       d  f       NŠ= f! , (       d  f       N<= f)zK
Adding a filesystem file reader to a reactor will make sure it is
polled.
c                   ó&   >• \ rS rSrSrU 4S jrSrg)Ú4StdioFilesTests.test_addReader.<locals>.DataProtocolé#   r   c                 ór   >• U =R                   U-  sl         U R                   S:X  a  TR                  5         g g )Nó   hello!)ÚdataÚstop)r   r   Úreactors     €r   ÚdataReceivedÚAStdioFilesTests.test_addReader.<locals>.DataProtocol.dataReceived&   s-   ø€ Ø—	’	˜TÑ!•	ð —9‘9 	Ó)Ø—L‘L•Nð *r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r    Ú__static_attributes__©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ô 		#ð �{‰{‹}ˆä�$˜Ô Ø�G‰G�IÔ÷ ô �$˜Ô á#“~ˆHÜØØ—h‘h“jØ—~‘~×,Ñ,Ó.Øò	ð �O‰O˜GÔ$÷ ð 	×Ñ˜Ÿ™¨	Õ2÷ Õú÷ Õús   Á CÁ&AC'Ã
C$Ã'
C5c                 óv  ^• U R                  5       m " U4S jS[        5      nU R                  5       n[        US5       nU" 5       n[	        UUR                  5       U R                  R                  5       TS9  UR                  R                  S5        UR                  R                  S5        UR                  R                  5         U R                  T5        SSS5        [        US5       nU R                  UR                  5       S	5        SSS5        g! , (       d  f       ND= f! , (       d  f       g= f)
zK
Adding a filesystem file writer to a reactor will make sure it is
polled.
c                   ó"   >• \ rS rSrU 4S jrSrg)Ú:StdioFilesTests.test_addWriter.<locals>.DisconnectProtocoléG   c                 ó&   >• TR                  5         g )N)r   )r   Úreasonr   s     €r   ÚconnectionLostÚIStdioFilesTests.test_addWriter.<locals>.DisconnectProtocol.connectionLostH   s   ø€ Ø—‘•r   r"   N)r#   r$   r%   r&   r=   r'   r(   s   €r   ÚDisconnectProtocolr9   G   s   ø† ÷ð r   r?   r   ©r-   r,   r   ó   hellos   , worldNr*   s   hello, world)r.   r   r   r   r   r0   r   Ú	transportr/   ÚloseConnectionr1   r2   Úread)r   r?   r   r3   r4   r   s        @r   Útest_addWriterÚStdioFilesTests.test_addWriter@   sô   ø€ ð
 ×#Ñ#Ó%ˆ÷	¤ô 	ð �{‰{‹}ˆä�$˜Ô ñ *Ó+ˆHÜØØ—x‘x“zØ—n‘n×+Ñ+Ó-Øò	ð ×Ñ×$Ñ$ XÔ.Ø×Ñ×$Ñ$ ZÔ0Ø×Ñ×-Ñ-Ô/à�O‰O˜GÔ$÷ ô  �$˜Ô Ø×Ñ˜QŸV™V›X Ô7÷ Ð÷! Õú÷  Õús   Á BDÃ/!D*Ä
D'Ä*
D8c                 ó  • U R                  5       nU R                  5       n[        US5      R                  5         [        US5       n[	        [        5       UR                  5       U R                  R                  5       US9nU R                  UR                  UR                  5       5        UR                  R                  5         U R                  UR                  UR                  5       5        SSS5        g! , (       d  f       g= f)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   r0   r   ÚassertInÚ_readerÚ
getReadersÚstopReadingÚassertNotIn©r   r   r   r3   Ústdios        r   Útest_removeReaderÚ!StdioFilesTests.test_removeReader`   s½   € ð
 ×#Ñ#Ó%ˆà�{‰{‹}ˆÜˆT�4Ó×ÑÔ ä�$˜Ô äÜ“
Ø—h‘h“jØ—~‘~×,Ñ,Ó.Øñ	ˆEð �M‰M˜%Ÿ-™-¨×);Ñ);Ó)=Ô>Ø�M‰M×%Ñ%Ô'Ø×Ñ˜UŸ]™]¨G×,>Ñ,>Ó,@ÔA÷ ×Öús   ÁB)C9Ã9
Dc                 óî  • U R                  5       n[        U R                  5       S5      =U l        n[	        5       n[        X2R                  5       U R                  R                  5       US9nUR                  R                  S5        U R                  UR                  UR                  5       5        UR                  R                  5         U R                  UR                  UR                  5       5        g)zY
Removing a filesystem file writer from a reactor will make sure it is
no longer polled.
r   r@   rA   N)r.   r   r   r3   r   r   r0   r   rB   r/   rH   Ú_writerÚ
getWritersÚstopWritingrL   )r   r   r3   r4   rN   s        r   Útest_removeWriterÚ!StdioFilesTests.test_removeWriterv   s¹   € ð
 ×#Ñ#Ó%ˆô ˜$Ÿ+™+›-¨Ó.Ð.ˆŒ�ô “:ˆÜØŸX™X›Z¨t¯~©~×/DÑ/DÓ/FÐPWñ
ˆð 	×Ñ× Ñ  Ô*Ø�‰�e—m‘m W×%7Ñ%7Ó%9Ô:Ø�‰×!Ñ!Ô#Ø×Ñ˜Ÿ™¨×(:Ñ(:Ó(<Õ=r   c                 ó¾  • U R                  5       nU R                  5       n[        US5      R                  5         [        US5      =U l        n[        [        5       UR                  5       U R                  R                  5       US9nUR                  5       nU R                  UR                  U5        U R                  UR                  UR                  5       5        g)zS
Calling C{removeAll} on a reactor includes descriptors that are
filesystem files.
r   r*   r+   N)r.   r   r   r   r3   r   r   r0   r   Ú	removeAllrH   rI   rL   rJ   )r   r   r   r3   rN   Úremoveds         r   Útest_removeAllÚStdioFilesTests.test_removeAllŠ   s±   € ð
 ×#Ñ#Ó%ˆà�{‰{‹}ˆÜˆT�4Ó×ÑÔ ô ˜$ Ó%Ð%ˆŒ�ô Ü‹JØ—(‘(“*Ø—>‘>×(Ñ(Ó*Øñ	
ˆð ×#Ñ#Ó%ˆØ�‰�e—m‘m WÔ-Ø×Ñ˜Ÿ™¨×(:Ñ(:Ó(<Õ=r   c                 óŒ  • U R                  5       nU R                  5       n[        US5      R                  5         [        US5       n[	        [        5       UR                  5       U R                  R                  5       US9nU R                  UR                  UR                  5       5        SSS5        g! , (       d  f       g= f)zG
C{reactor.getReaders} includes descriptors that are filesystem files.
r   r*   r+   N)r.   r   r   r   r   r   r0   r   rH   rI   rJ   rM   s        r   Útest_getReadersÚStdioFilesTests.test_getReaders£   s’   € ð ×#Ñ#Ó%ˆà�{‰{‹}ˆÜˆT�4Ó×ÑÔ ô �$˜Ô äÜ“
Ø—h‘h“jØ—~‘~×,Ñ,Ó.Øñ	ˆEð �M‰M˜%Ÿ-™-¨×);Ñ);Ó)=Ô>÷ ×Öús   ÁA%B5Â5
Cc                 ó¶  • U R                  5       n[        U R                  5       S5      =U l        n[	        [        5       UR                  5       U R                  R                  5       US9nU R                  UR                  UR                  5       5        UR                  R                  5         U R                  UR                  UR                  5       5        g)zG
C{reactor.getWriters} includes descriptors that are filesystem files.
r   r@   N)r.   r   r   r3   r   r   r0   r   rL   rR   rS   ÚstartWritingrH   )r   r   r3   rN   s       r   Útest_getWritersÚStdioFilesTests.test_getWriters·   s¤   € ð ×#Ñ#Ó%ˆô ˜$Ÿ+™+›-¨Ó.Ð.ˆŒ�ô Ü‹JØ—8‘8“:Ø—.‘.×'Ñ'Ó)Øñ	
ˆð 	×Ñ˜Ÿ™¨×(:Ñ(:Ó(<Ô=Ø�‰×"Ñ"Ô$Ø�‰�e—m‘m W×%7Ñ%7Ó%9Õ:r   zoStandardIO does not accept stdout as an argument to Windows. Testing redirection to a file is therefore harder.)r   r3   N)r#   r$   r%   r&   Ú__doc__r   r5   rE   rO   rU   rZ   r]   ra   r   Ú	isWindowsÚskipr'   r"   r   r   r   r      sS   † ñò.ò"3òH8ò@Bò,>ò(>ò2?ò(;ð( ×Ò×ÑðAó 	ò r   r   N)rc   Útwisted.internet.protocolr   Ú#twisted.internet.test.reactormixinsr   Útwisted.python.runtimer   rd   Útwisted.internet.stdior   r   ÚglobalsÚupdateÚmakeTestCaseClassesr"   r   r   Ú<module>rm      sQ   ðñõ
 /Ý >Ý +à×Ò×ÑÝ1ô~
�nô ~
ñB ƒ	× Ñ �×4Ñ4Ó6Õ 7r   