ó
    Ö›‘h  ã                  óˆ   • S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  \S:X  a  SSK
JrJr  SSKJr  OS	r " S
 S\	5      rg)zX
Tests for L{twisted.internet._sigchld}, an alternate, superior SIGCHLD
monitoring API.
é    )ÚannotationsN)ÚplatformType)ÚSynchronousTestCaseÚposix)ÚinstallHandlerÚisDefaultHandler)ÚsetNonBlockingz,These tests can only run on POSIX platforms.c                  ó^   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrS
rg)ÚSetWakeupSIGCHLDTestsé   zm
Tests for the L{signal.set_wakeup_fd} implementation of the
L{installHandler} and L{isDefaultHandler} APIs.
c                óâ   • [         R                  " 5       u  pU R                  [         R                  U5        U R                  [         R                  U5        [	        U5        [	        U5        X4$ )zS
Create a non-blocking pipe which will be closed after the currently
running test.
)ÚosÚpipeÚ
addCleanupÚcloser	   ©ÚselfÚreadÚwrites      ÚfC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_sigchld.pyr   ÚSetWakeupSIGCHLDTests.pipe   sM   € ô
 —g’g“i‰ˆØ�‰œŸ™ $Ô'Ø�‰œŸ™ %Ô(Ü�tÔÜ�uÔØˆ{Ðó    c                óv   • [         R                  " [         R                  5      U l        [	        S5      U l        g)z…
Save the current SIGCHLD handler as reported by L{signal.signal} and
the current file descriptor registered with L{installHandler}.
éÿÿÿÿN)ÚsignalÚ	getsignalÚSIGCHLDÚsignalModuleHandlerr   ÚoldFD©r   s    r   ÚsetUpÚSetWakeupSIGCHLDTests.setUp*   s'   € ô
 $*×#3Ò#3´F·N±NÓ#CˆÔ Ü# BÓ'ˆ�
r   c                óŒ   • [        U R                  5        [        R                  " [        R                  U R                  5        g)z=
Restore whatever signal handler was present when setUp ran.
N)r   r   r   r   r   r    s    r   ÚtearDownÚSetWakeupSIGCHLDTests.tearDown2   s(   € ô
 	�t—z‘zÔ"Ü�Š”f—n‘n d×&>Ñ&>Õ?r   c                óä  • U R                  [        5       5        [        R                  " [        R                  [        R                  5        U R                  [        5       5        [        R                  " [        R                  [        R                  5        U R                  [        5       5        [        R                  " [        R                  S 5        U R                  [        5       5        g)zV
L{isDefaultHandler} returns true if the SIGCHLD handler is SIG_DFL,
false otherwise.
c                 ó   • g )N© )Úargss    r   Ú<lambda>Ú=SetWakeupSIGCHLDTests.test_isDefaultHandler.<locals>.<lambda>D   s   € °Dr   N)Ú
assertTruer   r   r   ÚSIG_IGNÚassertFalseÚSIG_DFLr    s    r   Útest_isDefaultHandlerÚ+SetWakeupSIGCHLDTests.test_isDefaultHandler:   s‡   € ð
 	�‰Ô(Ó*Ô+Ü�Š”f—n‘n¤f§n¡nÔ5Ø×ÑÔ)Ó+Ô,Ü�Š”f—n‘n¤f§n¡nÔ5Ø�‰Ô(Ó*Ô+Ü�Š”f—n‘nÑ&8Ô9Ø×ÑÔ)Ó+Õ,r   c                ót   • U R                  5       u  p[        U5      nU R                  [        U5      U5        g)zF
L{installHandler} returns the previously registered file descriptor.
N)r   r   ÚassertEqual)r   r   r   r   s       r   Útest_returnOldFDÚ&SetWakeupSIGCHLDTests.test_returnOldFDG   s0   € ð —i‘i“k‰ˆÜ˜uÓ%ˆØ×Ñœ¨Ó.°Õ6r   c                óê   • U R                  5       u  pU R                  [        5       5        [        U5        U R	                  [        5       5        [        S5        U R                  [        5       5        g)z?
C{installHandler(-1)} removes the SIGCHLD handler completely.
r   N)r   r,   r   r   r.   r   s      r   Útest_uninstallHandlerÚ+SetWakeupSIGCHLDTests.test_uninstallHandlerO   sS   € ð —i‘i“k‰ˆØ�‰Ô(Ó*Ô+Ü�uÔØ×ÑÔ)Ó+Ô,Ü�rÔØ�‰Ô(Ó*Õ+r   c                ó®  • U R                  5       u  p[        U5        U R                  [        [        R
                  US5      nU R                  UR                  [        R                  5        [        R                  " [        R                  " 5       [        R                  5        U R                  [        [        R
                  " US5      5      S5        g)zt
The file descriptor passed to L{installHandler} has a byte written to
it when SIGCHLD is delivered to the process.
é   é   N)r   r   ÚassertRaisesÚOSErrorr   r   r3   ÚerrnoÚEAGAINÚkillÚgetpidr   r   Úlen)r   r   r   Úexcs       r   Útest_installHandlerÚ)SetWakeupSIGCHLDTests.test_installHandlerZ   sƒ   € ð
 —i‘i“k‰ˆÜ�uÔà×Ñ¤¬¯©°$¸Ó:ˆØ×Ñ˜Ÿ™¤E§L¡LÔ1ä
�Š”—	’	“œVŸ^™^Ô,à×ÑœœRŸWšW T¨1Ó-Ó.°Õ2r   )r   r   N)Úreturnztuple[int, int])rF   ÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r!   r$   r0   r4   r7   rD   Ú__static_attributes__r(   r   r   r   r      s+   † ñô

ô(ô@ô-ô7ô	,÷3r   r   )rL   Ú
__future__r   r>   r   r   Útwisted.python.runtimer   Útwisted.trial.unittestr   Útwisted.internet._signalsr   r   Útwisted.internet.fdescr	   Úskipr   r(   r   r   Ú<module>rT      s@   ðñõ #ã Û 	Û å /Ý 6à�7ÓßJÞ5à9€DôO3Ð/õ O3r   