python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_urllibnet.cpython-312.opt-1.pyc

Αe%8ddlZddlmZddlmZddlmZddlZddlZddlZ	ddl
Z	ddlZddlZ
ddlZejdGddej ZGdd	ej ZGd
dej Zedk(rej*yy)
N)support)	os_helper)
socket_helpernetworkceZdZdZdZdZy)URLTimeoutTestcJtjtjyN)socketsetdefaulttimeoutrINTERNET_TIMEOUTselfs G/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_urllibnet.pysetUpzURLTimeoutTest.setUps  !9!9:c.tjdyr
)rrrs rtearDownzURLTimeoutTest.tearDowns  &rc|jtjjtjjtjj}tj|5tjjtj}|jdddy#1swYyxYwr
)
addCleanupurllibrequest
urlcleanupparseurlparser
TEST_HTTP_URLnetlocrtransient_interneturlopenread)rdomainfs   rtestURLreadzURLTimeoutTest.testURLreads~112&&w'<'<=DD

-
-f
5	&&w'<'<=A
FFH			s6>B==CN)__name__
__module____qualname__rrr#rrrrs;'rrceZdZdZdZdZejdZdZ	dZ
dZdZd	Z
ejd
dZy)
urlopenNetworkTestsaATests urllib.request.urlopen using the network.

    These tests are not exhaustive.  Assuming that testing using files does a
    good job overall of some of the basic interface features.  There are no
    tests exercising the optional 'data' and 'proxies' arguments.  No tests
    for transparent redirection have been written.

    setUp is not used for always constructing a connection to
    http://www.pythontest.net/ since there a few tests that don't use that address
    and making a connection is expensive enough to warrant minimizing unneeded
    connections.

    http://www.pythontest.net/cV|jtjjyr
rrrrrs rrzurlopenNetworkTests.setUp6112rc/K|d}tj|5tjj|i|}	||j	dddy#|jwxYw#1swYyxYwwNr)rrrrrclose)rargskwargsresourcers     rrzurlopenNetworkTests.urlopen:so7

-
-h
7	&&77A
			
			s3A= A1AA1	A=A..A11A:6A=c|j|j5}dD]!}|jt||d|z#|j|j	ddddy#1swYyxYw)N)r readline	readlinesfilenor0infogeturlz3object returned from urlopen lacks the %s attributezcalling 'read' failed)rurl
assertTruehasattrr )ropen_urlattrs   r
test_basiczurlopenNetworkTests.test_basicDs|
\\$((
#	Fx+
I$ 7:ACG:HI
I
OOHMMO-DE	F	F	FsAA,,A5c|j|j5}|j|jtd|j|jtddddy#1swYyxYw)Nz readline did not return a stringzreadlines did not return a list)rr;assertIsInstancer6bytesr7list)rr>s  rtest_readlinesz"urlopenNetworkTests.test_readlinesMsk
\\$((
#	Ex!!("3"3"5u"D
F!!("4"4"6"C
E	E	E	EsAA00A9c|j|j5}|j}|j|tj
jd|j|jddddy#1swYyxYw)NzEobject returned by 'info' is not an instance of email.message.Messagehtml)	rr;r9rBemailmessageMessageassertEqualget_content_subtype)rr>info_objs   r	test_infozurlopenNetworkTests.test_infoUsv
\\$((
#	Ex}}H!!(EMM,A,A#F
G
X99;VD	E	E	EsABB
c|j|j5}|j}|j||jdddy#1swYyxYwr
)rr;r:rK)rr>
gotten_urls   rtest_geturlzurlopenNetworkTests.test_geturl^sI
\\$((
#	3x!*JZ2	3	3	3s-AAc|jdz}tj|5|jt5t
jjj|}ddd	j}|j|j|ddddy#1swYExYw#jwxYw#1swYyxYw)N
XXXinvalidXXXi)r;rrassertWarnsDeprecationWarningrrFancyURLopeneropengetcoder0rK)rURLr>codes    rtest_getcodez urlopenNetworkTests.test_getcodedshh(

-
-c
2	(!!"45
E!>>88:??D
E
!'') T3'	(	(
E
E
 
	(	(s:C.B-)C2B9"C-B6	2C9CCCwalltimec2d}	tj||jd|zd}|j	t|5t
jjdj|dddy#t$rY\wxYw#1swYyxYw)Nzsadflkjsasf.i.nvali.d.z&%r should not resolve for test to workzuopening an invalid URL did not raise OSError; can be caused by a broken DNS server (e.g. returns 404 or hijacks page)msgz
http://{}/)	r
gethostbynameskipTestOSErrorassertRaisesrrrformat)rbogus_domainfailure_explanations   rtest_bad_addressz$urlopenNetworkTests.test_bad_addressps,0		S  .
MMB\QR D

w,?

@	FNN""<#6#6|#DE	F	F	
			F	FsA>/B
>	B
	B

BN)r$r%r&__doc__r;r
contextlibcontextmanagerrr@rErNrQr[rrequires_resourcergr'rrr)r)%sl'C3FEE3
(Wz*$F+$Frr)ceZdZdZdZejdZdZdZ	dZ
dZejdd	Zd
Zy)urlretrieveNetworkTestsz3Tests urllib.request.urlretrieve using the network.cV|jtjjyr
r,rs rrzurlretrieveNetworkTests.setUpr-rc/K|d}tj|5tjj|i|\}}	||ftj|	dddy#tj|wxYw#1swYyxYwwr/)rrrrurlretrieverunlink)rr1r2r3
file_locationr9s      rrpz#urlretrieveNetworkTests.urlretrieves7

-
-h
7	0"(.."<"<d"Mf"MM4
0#T))  /	0	0
  /	0	0s4B#BA&B	B&A==BB	BcJ|j|j5\}}|jtjj|dt
|d5}|j|jdddddddy#1swYxYw#1swYyxYw)Nz9file location returned by urlretrieve is not a valid pathrbz=reading from the file location returned by urlretrieve failed)rplogor<ospathexistsrWr rrrr9r"s    rr@z"urlretrieveNetworkTests.test_basics


dii
(	:,A]DOOBGGNN=9<?
@mT*
:a+9:
:	:	:
:
:	:	:s#?B!B
<B
B	BB"c|j|jtj5\}}|j	|tj|jtjj|t|d5}|j|jdddddddy#1swYxYw#1swYyxYw)Nrtz"reading from temporary file failed)rprurTESTFNrKr<rvrwrxrWr rys    rtest_specified_pathz+urlretrieveNetworkTests.test_specified_paths


dii'..0	P3HM4]I,<,<=OOBGGNN=9:mT*
Pa*NO
P		P	P
P
P		P	Ps$AC	!B;*C;C	CCc|j|j5\}}|j|tjj
ddddy#1swYyxYw)Nz0info is not an instance of email.message.Message)rprurBrHrIrJ)rrrr9s   rtest_headerz#urlretrieveNetworkTests.test_headersT


dii
(	V,A]D!!$

(=(="T
V	V	V	Vs/AAr*r\c|j|j5\}}|jd}d}	tj||dddy#t
$r|j
d|zY(wxYw#1swYyxYw)NDatez%a, %d %b %Y %H:%M:%S GMTzDate value not in %r format)rprugettimestrptime
ValueErrorfail)rrrfileheaders	datevalue
dateformats     rtest_data_headerz(urlretrieveNetworkTests.test_data_headers


dii
(	F,H]K#/I4J
F

i4		F	F

F		7*DE
F	F	Fs(A6AA30A62A33A66A?cr	g		fd}|j|j|5\}}t|d}dddt	}|j	t	dd|j
	ddd|j		dddd|z|j
	dd	|j
	d
d	|	Dchc]\}}}|
}}}|j
	ddh|d|z|j	d
d	ddz|d|zy#1swYxYwcc}}w)
Nc.j|||fyr
)append)blocks
block_size
total_sizerecordss   rrecording_reporthookzEurlretrieveNetworkTests.test_reporthook.<locals>.recording_reporthooksNNFJ
;<r)
reporthookzContent-LengthzKThere should always be two calls; the first one before the transfer starts.r^rzblock size can't be 0 in %szblock sizes in %s must be equalz9number of blocks * block size must be >= total size in %s)rpruintrepr
assertGreaterlenrKassertGreaterEqual)
rrrrr
expected_sizerecords_repr_rblock_sizesrs
         @rtest_reporthookz'urlretrieveNetworkTests.test_reporthooksv	=

dii4H

I	?N,{,< =>M	?G}3w<1N	OA*71:a=!<|K		MA
6Q7:AB&6aQzBB'!*Q-+>M		OAwqz!} <m%79E%F	 	G!	?	?CsD'
D3'D0N)r$r%r&rhrrirjrpr@r|r~rurrkrrr'rrrmrmsc=300:PV(DWz*F+FGrrm__main__)unittesttestrtest.supportrrrirurllib.parserurllib.requestrv
email.messagerHrrequiresTestCaserr)rmr$mainr'rr<module>rs"&
	X&&&pF(++pFfMGh//MG`zHMMOr