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: //usr/local/lib/python3.10/test/__pycache__/test_timeout.cpython-310.opt-2.pyc
o

�i�+�@s�	ddlZddlZddlmZddlmZe�d�ZddlZddl	Z	ddl
Z
e��dd��ZGdd�dej
�ZGd	d
�d
ej
�ZGdd�de�ZGd
d�de�Zdd�Zedkr_e��dSdS)�N)�support)�
socket_helper�networkcCsL	t�|��t�||tjtj�ddWd�S1swYdS)Nr�)r�transient_internet�socket�getaddrinfo�AF_INET�SOCK_STREAM)�host�port�r
�./usr/local/lib/python3.10/test/test_timeout.py�resolve_addresss���$�rc@sVeZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�CreationTestCasecC�t�tjtj�|_dS�N)rr	r
�sock��selfr
r
r�setUp�zCreationTestCase.setUpcC�|j��dSr�r�closerr
r
r�tearDown"�zCreationTestCase.tearDowncCs|�|j��dd�dS)Nztimeout not disabled by default)�assertEqualr�
gettimeoutrr
r
r�testObjectCreation%s�z#CreationTestCase.testObjectCreationcCs^|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|�|j��d�dS)Ng�z�Ga@�)r�
settimeoutrrrr
r
r�testFloatReturnValue*sz%CreationTestCase.testFloatReturnValuecCsP|j�d�|�t|j���td��|j�d�|�t|j���td��dS)N���?g333333@)rr!r�typerrr
r
r�testReturnType5szCreationTestCase.testReturnTypecCs�|j�d�|j�d�|j�d�|j�d�|�t|jjd�|�t|jjd�|�t|jjd�|�t|jjg�|�t|jji�|�t|jjd�dS)Nr��r
y)rr!�assertRaises�	TypeErrorrr
r
r�
testTypeCheck=szCreationTestCase.testTypeCheckcCs:|�t|jjd�|�t|jjd�|�t|jjd�dS)N���g�)r)�
ValueErrorrr!rr
r
r�testRangeCheckJszCreationTestCase.testRangeCheckcCs�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�dS)N�
TFr')rr!�setblockingrrrr
r
r�testTimeoutThenBlockingPsz(CreationTestCase.testTimeoutThenBlockingcCsX|j�d�|j�d�|�|j��d�|j�d�|j�d�|�|j��d�dS)NFr#T)rr0r!rrrr
r
r�testBlockingThenTimeout^sz(CreationTestCase.testBlockingThenTimeoutN)�__name__�
__module__�__qualname__rrrr"r&r+r.r1r2r
r
r
rrs
rc@s*eZdZdZejZdd�ZeZdd�Z	dS)�TimeoutTestCaseg@cCst��r)�NotImplementedErrorrr
r
rrtszTimeoutTestCase.setUpc	Gs�	|j�|�t|j|�}t|�D]%}t��}z||�Wqty6}z
t��|}WYd}~n
d}~ww|�d�|�|||j	�|�
||d�dS)NzTimeoutError was not raisedr$)rr!�getattr�range�time�	monotonic�TimeoutErrorZfailZ
assertLess�fuzzZ
assertGreater)	r�count�timeout�method�args�i�t1�eZdeltar
r
r�_sock_operationys��
zTimeoutTestCase._sock_operationN)
r3r4r5r=rZHOST�	localhostrrrEr
r
r
rr6isr6c@sZeZdZ	dd�Zdd�Ze�dd�dd��Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�TCPTimeoutTestCasecCs"t�tjtj�|_tdd�|_dS)Nzwww.python.org.�P)rr	r
rr�addr_remoterr
r
rr�szTCPTimeoutTestCase.setUpcCrrrrr
r
rr�rzTCPTimeoutTestCase.tearDownTz*need to replace these hosts; see bpo-35518c
Cs"tdd�}tdd�}d}t�tjtj�}tj}|�|�z1z|�|�Wn"ty-Ynt	yF}z|j
t
jkr<d}WYd}~nd}~wwW|��~n|��~w|rj|�
d�|d|d	||d|d	��||_t�|jd��|�d	d
d|j�Wd�dS1s�wYdS)Nzblackhole.snakebite.netiZ�zwhitehole.snakebite.neti[�TFz�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).rr#g����MbP?�connect)rrr	r
rZLOOPBACK_TIMEOUTr!rJr<�OSError�errnoZECONNREFUSEDrZskipTest�formatrIrrrE)rZ	blackholeZ	whitehole�skiprr?�errr
r
r�testConnectTimeout�sF


������"�z%TCPTimeoutTestCase.testConnectTimeoutcCsTt�|jd��|j�|j�|�dddd�Wd�dS1s#wYdS)Nrr#��?�recv�)rrrIrrJrErr
r
r�testRecvTimeout�s"�z"TCPTimeoutTestCase.testRecvTimeoutcCs,t�|j|j�|j��|�ddd�dS)Nr#rQ�accept)r�	bind_portrrF�listenrErr
r
r�testAcceptTimeout�s
z$TCPTimeoutTestCase.testAcceptTimeoutcC�pt�tjtj��&}t�||j�|��|j�|�	��|�
ddddd�Wd�dS1s1wYdS)N�drQ�send�X�@
�rr	r
rrVrFrWrrJ�getsocknamerE�rZservr
r
r�testSend��"�zTCPTimeoutTestCase.testSendc	Csvt�tjtj��)}t�||j�|��|j�|�	��|�
ddddd|�	��Wd�dS1s4wYdS)NrZrQ�sendtor\r]r^r`r
r
r�
testSendtos�"�zTCPTimeoutTestCase.testSendtocCrY)NrZrQ�sendallr\r]r^r`r
r
r�testSendallrbzTCPTimeoutTestCase.testSendallN)
r3r4r5rr�unittestZskipIfrPrTrXrardrfr
r
r
rrG�s

Q	
rGc@s&eZdZ	dd�Zdd�Zdd�ZdS)�UDPTimeoutTestCasecCrr)rr	�
SOCK_DGRAMrrr
r
rrrzUDPTimeoutTestCase.setUpcCrrrrr
r
rrrzUDPTimeoutTestCase.tearDowncCs$t�|j|j�|�dddd�dS)Nr#rQ�recvfromrS)rrVrrFrErr
r
r�testRecvfromTimeoutsz&UDPTimeoutTestCase.testRecvfromTimeoutN)r3r4r5rrrkr
r
r
rrhs
rhcCst�d�dS)Nr)rZrequiresr
r
r
r�setUpModule%rrl�__main__)�	functoolsrg�testrZtest.supportrZis_resource_enabledZ
skip_expectedr:rLr�	lru_cacherZTestCaserr6rGrhrlr3�mainr
r
r
r�<module>s(
M'�