python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_timeout.cpython-312.pyc

Αe**dZddlZddlZddlmZddlmZddlZddlZddl	Z	ejdZGddejZ
Gdd	ejZGd
deZGdd
eZdZedk(rej&yy)z&Unit tests for socket timeout feature.N)support)
socket_helperctj|5tj||tjtj
ddcdddS#1swYyxYw)zResolve an (host, port) to an address.

    We must perform name resolution before timeout tests, otherwise it will be
    performed by connect().
    rN)rtransient_internetsocketgetaddrinfoAF_INETSOCK_STREAM)hostports  E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_timeout.pyresolve_addressr
sX
	)	)$	/<!!$fnn"("4"466799:<<<<s:AA#cFeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
Zy)CreationTestCasez9Test case for socket.gettimeout() and socket.settimeout()crtjtjtj|_yN)rr
rsockselfs rsetUpzCreationTestCase.setUpsMM&..&2D2DE	c8|jjyrrclosers rtearDownzCreationTestCase.tearDown		rcZ|j|jjddy)Nztimeout not disabled by default)assertEqualr
gettimeoutrs rtestObjectCreationz#CreationTestCase.testObjectCreation"s$--/:	<rc|jjd|j|jjd|jjd|j|jjd|jjd|j|jjdy)NgzGa@)r
settimeoutrr rs rtestFloatReturnValuez%CreationTestCase.testFloatReturnValue's		U#--/7		Q--/3		T"--/6rcL|jjd|jt|jj	t
|jjd|jt|jj	t
y)Ng333333@)rr$assertIstyper floatrs rtestReturnTypezCreationTestCase.testReturnType2sf		Q

d499//12E:		S!

d499//12E:rc|jjd|jjd|jjd|jjd|jt|jjd|jt|jjd|jt|jjd|jt|jjg|jt|jji|jt|jjdy)Nry)rr$assertRaises	TypeErrorrs r
testTypeCheckzCreationTestCase.testTypeCheck:s		Q		Q		S!		T")TYY%9%92>)TYY%9%92>)TYY%9%92>)TYY%9%92>)TYY%9%92>)TYY%9%92>rc|jt|jjd|jt|jjd|jt|jjdy)Ng)r0
ValueErrorrr$rs rtestRangeCheckzCreationTestCase.testRangeCheckGsV*dii&:&:B?*dii&:&:B?*dii&:&:DArc|jjd|jjd|j|jj	d|jjd|j|jj	d|jjd|jjd|j|jj	d|jjd|j|jj	dy)N
TFr-)rr$setblockingrr rs rtestTimeoutThenBlockingz(CreationTestCase.testTimeoutThenBlockingMs		R 		d#--/6		e$--/5		R 		e$--/5		d#--/6rc|jjd|jjd|j|jj	d|jjd|jjd|j|jj	dy)NFr'T)rr9r$rr rs rtestBlockingThenTimeoutz(CreationTestCase.testBlockingThenTimeout[s		e$		Q--/3		d#		Q--/3rN)
__name__
__module____qualname____doc__rrr!r%r+r2r6r:r<r/rrrrs4CF<
	7;?B74rrc8eZdZdZej
ZdZeZdZ	y)TimeoutTestCaseg@ctr)NotImplementedErrorrs rrzTimeoutTestCase.setUpqs!##rc|jj|t|j|}t|D]}t	j
}	|||jd|j||jz|j||dz
y#t$r"}t	j
|z
}Yd}~[d}~wwxYw)z
        Test the specified socket method.

        The method is run at most `count` times and must raise a TimeoutError
        within `timeout` + self.fuzz seconds.
        NzTimeoutError was not raisedg?)rr$getattrrangetime	monotonicTimeoutErrorfail
assertLessfuzz
assertGreater)	rcounttimeoutmethodargsit1edeltas	         r_sock_operationzTimeoutTestCase._sock_operationvs	
		W%F+u	5A!B

	5
II34w235'C-0 
(2-
sB""	C
+CC
N)
r=r>r?rMrHOST	localhostrrrWr/rrrBrBfs%D""I$H1rrBc@eZdZdZdZdZdZdZdZdZ	dZ
d	Zy
)TCPTimeoutTestCasez3TCP test case for socket.socket() timeout functionsctjtjtj|_t	dd|_y)Nzwww.python.org.P)rr
rrraddr_remoters rrzTCPTimeoutTestCase.setUps.MM&..&2D2DE	*+<bArc8|jjyrrrs rrzTCPTimeoutTestCase.tearDownrrc
tdd}tdd}d}tjtjtj}tj
}|j
|	|j||j~|r0|jdj|d|d||d|d||_t!j"|jd5|j%dd	d
|jdddy#t$rYt$r)}|jtjk(rd}Yd}~d}~wwxYw#|j~wxYw#1swYyxYw)Nzpythontest.netiZi[TFzWe 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'gMbP?connect)rrr
rrLOOPBACK_TIMEOUTr$rarJOSErrorerrnoECONNREFUSEDrskipTestformatr^rrrW)r	blackhole	whiteholeskiprrPerrs       rtestConnectTimeoutz%TCPTimeoutTestCase.testConnectTimeoutsV
$$4e<	$$4e<	0}}V^^V-?-?@** 		LL)%
JJLMM8V!!!!!!!!
%

-
-d.>.>q.A
B	H  E9d6F6FG	H	H5		yyE...	
JJL&	H	HsB/D,E)	EEE'EEEEE&)E2ctj|jd5|jj	|j|jdddddddy#1swYyxYw)Nrr'?recv)rrr^rrarWrs rtestRecvTimeoutz"TCPTimeoutTestCase.testRecvTimeouts\

-
-d.>.>q.A
B	7IId../  C6	7	7	7s:A&&A/ctj|j|j|jj	|jdddy)Nr'rnaccept)r	bind_portrrYlistenrWrs rtestAcceptTimeoutz$TCPTimeoutTestCase.testAcceptTimeouts<		4>>:		QX.rcrtjtjtj5}tj||j
|j
|jj|j|jdddddzdddy#1swYyxYw)NdrnsendX@
rr
rrrtrYrurragetsocknamerWrservs  rtestSendzTCPTimeoutTestCase.testSends
]]6>>6+=+=
>	B$##D$..9KKMIId..01  c64&=A	B	B	BA1B--B6c	tjtjtj5}tj||j
|j
|jj|j|jdddddz|jdddy#1swYyxYw)Nrxrnsendtorzr{r|r~s  r
testSendtozTCPTimeoutTestCase.testSendtos
]]6>>6+=+=
>	5$##D$..9KKMIId..01  c8TF]!%!1!1!3
5	5	5	5sBB<<Ccrtjtjtj5}tj||j
|j
|jj|j|jdddddzdddy#1swYyxYw)Nrxrnsendallrzr{r|r~s  rtestSendallzTCPTimeoutTestCase.testSendalls
]]6>>6+=+=
>	E$##D$..9KKMIId..01  c9dVmD	E	E	ErN)r=r>r?r@rrrlrqrvrrrr/rrr[r[s3=BJHX7/B5Err[c"eZdZdZdZdZdZy)UDPTimeoutTestCasez3UDP test case for socket.socket() timeout functionscrtjtjtj|_yr)rr

SOCK_DGRAMrrs rrzUDPTimeoutTestCase.setUpsMM&..&2C2CD	rc8|jjyrrrs rrzUDPTimeoutTestCase.tearDownrrctj|j|j|j	ddddy)Nr'rnrecvfromrp)rrtrrYrWrs rtestRecvfromTimeoutz&UDPTimeoutTestCase.testRecvfromTimeouts0			4>>:QZ6rN)r=r>r?r@rrrr/rrrrs=E7rrcZtjdtjdy)NnetworkT)module)rrequiresrequires_working_socketr/rrsetUpModulersY##40r__main__)r@	functoolsunittesttestrtest.supportrrHrdr	lru_cacherTestCaserrBr[rrr=mainr/rr<module>rs,&
<<J4x((J4Z$1h''$1N|E|E~
7
7 1
zHMMOr