HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_timeout.cpython-37.opt-2.pyc
B

��g�,�@s�ddlZddlZddlmZe�d�ZddlZddlZddlZe�	�dd��Z
Gdd�dej�ZGdd	�d	ej�Z
Gd
d�de
�ZGdd
�d
e
�Zdd�Zedkr�e�dS)�N)�support�networkc	Cs2t�|��t�||tjtj�ddSQRXdS)Nr�)r�transient_internet�socketZgetaddrinfo�AF_INET�SOCK_STREAM)ZhostZport�r	�-/usr/local/lib/python3.7/test/test_timeout.py�resolve_addresssrc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�CreationTestCasecCst�tjtj�|_dS)N)rrr�sock)�selfr	r	r
�setUpszCreationTestCase.setUpcCs|j��dS)N)r
�close)rr	r	r
�tearDown!szCreationTestCase.tearDowncCs|�|j��dd�dS)Nztimeout not disabled by default)�assertEqualr
�
gettimeout)rr	r	r
�testObjectCreation$sz#CreationTestCase.testObjectCreationcCs^|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|�|j��d�dS)Ng�z�Ga@�)r
�
settimeoutrr)rr	r	r
�testFloatReturnValue)sz%CreationTestCase.testFloatReturnValuecCsP|j�d�|�t|j���td��|j�d�|�t|j���td��dS)N�g�?g333333@)r
rr�typer)rr	r	r
�testReturnType4szCreationTestCase.testReturnTypecCs�|j�d�|j�d�|j�d�|j�d�|�t|jjd�|�t|jjd�|�t|jjd�|�t|jjg�|�t|jji�|�t|jjd�dS)Nrg�r	y)r
r�assertRaises�	TypeError)rr	r	r
�
testTypeCheck<szCreationTestCase.testTypeCheckcCs:|�t|jjd�|�t|jjd�|�t|jjd�dS)N���g�)r�
ValueErrorr
r)rr	r	r
�testRangeCheckIszCreationTestCase.testRangeCheckcCs�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�dS)N�
rrg)r
r�setblockingrr)rr	r	r
�testTimeoutThenBlockingOsz(CreationTestCase.testTimeoutThenBlockingcCsX|j�d�|j�d�|�|j��d�|j�d�|j�d�|�|j��d�dS)Nrr)r
r#rrr)rr	r	r
�testBlockingThenTimeout]sz(CreationTestCase.testBlockingThenTimeoutN)�__name__�
__module__�__qualname__rrrrrrr!r$r%r	r	r	r
rs
rc@s*eZdZdZejZdd�ZeZdd�Z	dS)�TimeoutTestCaseg@cCs
t��dS)N)�NotImplementedError)rr	r	r
rsszTimeoutTestCase.setUpc	Gs�|j�|�t|j|�}xbt|�D]L}t��}y||�Wq"tjk
rl}zt��|}PWdd}~XYq"Xq"W|�d�|�	|||j
�|�||d�dS)Nzsocket.timeout was not raisedg�?)r
r�getattr�range�timeZ	monotonicr�timeoutZfailZ
assertLess�fuzzZ
assertGreater)	r�countr.�method�args�iZt1�eZdeltar	r	r
�_sock_operationxs
zTimeoutTestCase._sock_operationN)
r&r'r(r/rZHOST�	localhostrrr5r	r	r	r
r)hs
r)c@sXeZdZdd�Zdd�Ze�dd�dd��Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�TCPTimeoutTestCasecCs"t�tjtj�|_tdd�|_dS)Nzwww.python.org.�P)rrrr
r�addr_remote)rr	r	r
r�szTCPTimeoutTestCase.setUpcCs|j��dS)N)r
r)rr	r	r
r�szTCPTimeoutTestCase.tearDownTz*need to replace these hosts; see bpo-35518c
Cstdd�}tdd�}d}t�tjtj�}d}|�|�zZy|�|�WnFtjk
r\Yn2tk
r�}z|jtj	kr|d}Wdd}~XYnXWd|�
�~X|r�|�d�|d	|d
||d	|d
��||_
t�|j
d	��|�d
dd|j
�WdQRXdS)
Nzblackhole.snakebite.netiZ�zwhitehole.snakebite.neti[�TrFz�We didn't receive a connection reset (RST) packet from {}:{} within {} seconds, so we're unable to test connect timeout against the corresponding {}:{} (which is configured to silently drop packets).rrg����MbP?�connect)rrrrrr:r.�OSError�errnoZECONNREFUSEDrZskipTest�formatr9rrr5)rZ	blackholeZ	whitehole�skipr
r.�errr	r	r
�testConnectTimeout�s4


z%TCPTimeoutTestCase.testConnectTimeoutc	Cs>t�|jd��$|j�|j�|�dddd�WdQRXdS)Nrrg�?Zrecvi)rrr9r
r:r5)rr	r	r
�testRecvTimeout�sz"TCPTimeoutTestCase.testRecvTimeoutcCs,t�|j|j�|j��|�ddd�dS)Nrg�?Zaccept)r�	bind_portr
r6�listenr5)rr	r	r
�testAcceptTimeout�s
z$TCPTimeoutTestCase.testAcceptTimeoutc	CsZt�tjtj��@}t�||j�|��|j�|�	��|�
ddddd�WdQRXdS)N�dg�?�send�Xi@
)rrrrrBr6rCr
r:�getsocknamer5)r�servr	r	r
�testSend�s
zTCPTimeoutTestCase.testSendc	Cs`t�tjtj��F}t�||j�|��|j�|�	��|�
ddddd|�	��WdQRXdS)NrEg�?ZsendtorGi@
)rrrrrBr6rCr
r:rHr5)rrIr	r	r
�
testSendtoszTCPTimeoutTestCase.testSendtoc	CsZt�tjtj��@}t�||j�|��|j�|�	��|�
ddddd�WdQRXdS)NrEg�?ZsendallrGi@
)rrrrrBr6rCr
r:rHr5)rrIr	r	r
�testSendall
s
zTCPTimeoutTestCase.testSendallN)
r&r'r(rr�unittestZskipIfr@rArDrJrKrLr	r	r	r
r7�sU	
r7c@s$eZdZdd�Zdd�Zdd�ZdS)�UDPTimeoutTestCasecCst�tjtj�|_dS)N)rrZ
SOCK_DGRAMr
)rr	r	r
rszUDPTimeoutTestCase.setUpcCs|j��dS)N)r
r)rr	r	r
rszUDPTimeoutTestCase.tearDowncCs$t�|j|j�|�dddd�dS)Nrg�?Zrecvfromi)rrBr
r6r5)rr	r	r
�testRecvfromTimeout sz&UDPTimeoutTestCase.testRecvfromTimeoutN)r&r'r(rrrOr	r	r	r
rNsrNcCst�d�t�ttt�dS)Nr)rZrequiresZrun_unittestrr7rNr	r	r	r
�	test_main's

rP�__main__)�	functoolsrMZtestrZis_resource_enabledZ
skip_expectedr-r<r�	lru_cacherZTestCaserr)r7rNrPr&r	r	r	r
�<module>sM'