}#6SrSSKrSSKrSSKrSSKrSSKrSSK r SSK r SSK J r SSK Jr SSKJr SSKJr SSKJr SSKJr SSKrSSKrSSKrSSKrSS KJr SSKr\R:(d\ R<"S 5eS rSq S0S jr!S r"S1Sjr#"SS\$5r%"SS\$5r&"SS\ RN\5r("SS\ RN5r)"SS\ RN5r*"SS\ RN\%\&5r+"SS\ RN\5r,"SS\ RN5r-"SS \ RN\%5r."S!S"\ RN5r/"S#S$\ RN5r0"S%S&\ RN5r1"S'S(\ RN5r2"S)S*\ RN5r3"S+S,\%\ RN5r4"S-S.\ RN5r5\6S/:Xa\ Rn"5 gg!\a SrGNf=f)2z;Regression tests for what was in Python 2's "urllib" moduleN)patch)support) os_helper) socket_helper)warnings_helper)ExtraAssertions) b64encodeztest requires gethostname()c~[[U55SSR5n[U5S:XaSU-nSU-$)z!Escape char as RFC 2396 specifiesNz0%s%)hexordupperlen)charhex_reprs 7/opt/alt/python313/lib64/python3.13/test/test_urllib.py hexescaper s?3t9~ab!'')H 8}8# >cUb[RRUS9nO[(d [5nUqO[nUcUR U5$UR X5$)z.urlopen(url [, data]) -> open file-like object)proxies)urllibrequestFancyURLopener _urlopeneropen)urldataropeners rurlopenr!+s[..w.? Z!  |{{3{{3%%rc[R"S[45 [RR 5sSSS5 $!,(df  g=f)Nz8FancyURLopener style of invoking requests is deprecated.)rcheck_warningsDeprecationWarningrrrrrrr;s=  ' ' G   !~~,,. ! ! !s A Ac^^^"U4SjS[R5m"UU4SjS[RR5mUTlT$)NcF>\rSrSrSrU4SjrSrS SjrS SjrSr S r g) fakehttp..FakeSocketCr c>UTlgN)buf)selfrFakeHTTPConnections rsendall$fakehttp..FakeSocket.sendallFs %)  "rc0U=RS- slU$)Nr )io_refs)r-argskwdss rmakefile%fakehttp..FakeSocket.makefileIs LLA LKrNcdUR(ag[RRX5$Nr)closedioBytesIOread)r-amts rr<!fakehttp..FakeSocket.readMs{{::??4- -rcdUR(ag[RRX5$r8)r9r:r;readline)r-lengths rr@%fakehttp..FakeSocket.readlineRs!{{::&&t4 4rcU=RS-slURS:Xa [RRU5 gg)Nr r)r2r:r;closer-s rrD"fakehttp..FakeSocket.closeWs3 LLA L||q    &!rr%r+) __name__ __module__ __qualname____firstlineno__r2r/r5r<r@rD__static_attributes__)r.sr FakeSocketr(Cs! *  .  5  'rrLcB>\rSrSrSrU4SjrY(aSrSrgSrg)$fakehttp..FakeHTTPConnection\Nch>T"UR5UlUR[U5lgr+)fakedatasocktypefakesock)r-rLs rconnect,fakehttp..FakeHTTPConnection.connectas#"4==1DI"&))DJ rcgr+r%rEs rrD*fakehttp..FakeHTTPConnection.closejr)rR)rGrHrIrJr,rUrDrK)rL mock_closesrr.rN\s ,    rr.)r:r;httpclientHTTPConnectionrQ)rQrZr.rLs `@@rfakehttpr^Bs?'RZZ'2T[[77 #+ rc$\rSrSrSSjrSrSrg) FakeHTTPMixinqc~[XS9n[RRUlU[Rlg)NrZ)r^r[r\r]_connection_class)r-rQrZfake_http_classs rr^FakeHTTPMixin.fakehttprs*"8C!%!;!;%4 "rcBUR[Rlgr+)rdr[r\r]rEs r unfakehttpFakeHTTPMixin.unfakehttpws%)%;%; "r)rdNF)rGrHrIrJr^rhrKr%rrr`r`qs 5 .FakeFtpWrapper}Ncgr+r%)r-userpasswdhostportdirstimeout persistents r__init__5FakeFTPMixin.fakeftp..FakeFtpWrapper.__init__~src0[R"5S4$)Nr)r:r;)r-filerSs rretrfile5FakeFTPMixin.fakeftp..FakeFtpWrapper.retrfileszz|Q&rcgr+r%rEs rrD2FakeFTPMixin.fakeftp..FakeFtpWrapper.closerYrr%)NT)rGrHrIrJrzr~rDrKr%rrFakeFtpWrapperrp}sHL $  ' rr)objectrr ftpwrapper_ftpwrapper_class)r-rs rfakeftpFakeFTPMixin.fakeftp|s. V "(!:!:$2!rcBUR[Rlgr+)rrrrrEs r unfakeftpFakeFTPMixin.unfakeftps$($:$:!r)rN)rGrHrIrJrrrKr%rrrlrl{s  3;rrlcx\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSrSrSrSrSrSrg)urlopen_FileTestszTest urlopen() opening a temporary file. Try to test as much functionality as possible so as to cut down on reliance on connecting to the Net for testing. c[SURR-S5Ul[ [ R S5nURUR5 UR5 [ R Ul [RR[R"UR55Ul[!SUR-5Ulg!UR5 f=f)Nztest_urllib: %s asciiwbfile:%s)bytes __class__rGtextrrTESTFNwriterDpathnamerparsequoteosfsencodequoted_pathnamer! returned_obj)r-fs rsetUpurlopen_FileTests.setUps-0G0GG!# !!4 (  GGDII  GGI!(( %||11"++dmm2LM#I0D0D$DE GGIs C$$C6cURR5 [R"[R 5 g)zShut down the open objectN)rrDrremoverrrEs rtearDownurlopen_FileTests.tearDowns& ! )""#rcNSHnURURU5 M! g)N) r<r@ readlinesfilenorDinfogeturlgetcode__iter__) assertHasAttrrr-attrs rtest_interface urlopen_FileTests.test_interfaces&GD   t00$ 7GrclURURURR55 gr+) assertEqualrrr<rEs r test_readurlopen_FileTests.test_reads% D$5$5$:$:$<=rcURURURR55 URSURR5S5 g)NrzKcalling readline() after exhausting the file did not return an empty string)rrrr@rEs r test_readlineurlopen_FileTests.test_readlinesK D$5$5$>$>$@A d//88:3 4rcURR5nUR[U5SS5 URUSURS5 g)Nr z.readlines() returned the wrong number of linesrz"readlines() returned improper text)rrrrr)r- lines_lists rtest_readlines urlopen_FileTests.test_readlinessM&&002  Z!I K A = ?rcURR5nURU[S5 UR [ R "U[UR55URS5 g)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text) rrassertIsInstanceintrrr<rr)r-file_nums r test_filenourlopen_FileTests.test_filenosW$$++- h-MN 3tyy>:DII< =rc8URR5 gr+)rrDrEs r test_closeurlopen_FileTests.test_closes !rcURURR[RR 5 gr+)rrheadersemailmessageMessagerEs r test_headersurlopen_FileTests.test_headerss( d//779N9NOrcdURURRUR5 gr+)rrrrrEs rtest_urlurlopen_FileTests.test_urls$ **..0D0DErcNURURR5 gr+) assertIsNonerstatusrEs r test_statusurlopen_FileTests.test_statuss $++223rcURURR5[RR 5 gr+)rrrrrrrEs r test_infourlopen_FileTests.test_infos+ d//446 8M8MNrclURURR5UR5 gr+)rrrrrEs r test_geturlurlopen_FileTests.test_geturls' **113T5I5IJrcVURURR55 gr+)rrrrEs r test_getcodeurlopen_FileTests.test_getcodes $++3356rc`URHnURXR5 M gr+)rrr)r-lines r test_iterurlopen_FileTests.test_iters& %%D   T99 -&rc|UR[[RRSUR -5 g)Nz./) assertRaises ValueErrorrrr!rrEs rtest_relativelocalfile(urlopen_FileTests.test_relativelocalfiles' *V^^%;%;D4==4 ?=" PF4OK7.Rrrc8\rSrSrSrSrSrSrSrSr Sr g ) ProxyTestscUR[R"55Ul[ [ R 5H4nSUR5;dMURRU5 M6 g)Nproxy) enterContextrEnvironmentVarGuardenvlistrenvironlowerunset)r-ks rrProxyTests.setUpsN$$Y%B%B%DEbjj!A!'')#q!"rcURRSS5 [RR 5nUR SUS5 URRSS5 UR [RRS55 UR [RRS55 UR [RRS55 g)NNO_PROXY localhostno0localhost, anotherdomain.com, newdomain.com:1234anotherdomain.comanotherdomain.com:8888newdomain.com:1234)rsetrrgetproxies_environmentr assertTrueproxy_bypass_environmentr-rs r+test_getproxies_environment_keep_no_proxies6ProxyTests.test_getproxies_environment_keep_no_proxiess  Z-..779 gdm4  Z!ST ??@STU ??@XYZ ??@TUVrcURRSS5 [RR 5nUR SUS5 URRSS5 [RR 5nUR SU5 URRS5 URRS5 g!URRS5 URRS5 f=f)N HTTP_PROXYhttp://somewhere:3128r[REQUEST_METHODGET)rrrrrr assertNotInrrs rtest_proxy_cgi_ignore ProxyTests.test_proxy_cgi_ignores ) HHLL'> ?nn;;=G   4gfo F HHLL)5 1nn;;=G   VW - HHNN+ , HHNN< ( HHNN+ , HHNN< (s BC8D c[RRnURR SS5 UR U"S55 UR U"S55 UR U"S55 UR U"S55 UR U"S55 UR U"S55 UR U"S 55 UR U"S 55 UR U"S 55 UR U"S 55 UR U"S 55 UR U"S55 UR U"S55 UR U"S55 g)Nrz8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr LocalHost LOCALHOSTz .localhostrz.newdomain.com:1234z foo.d.o.tzd.o.trz.anotherdomain.com:8888zwww.newdomain.com:1234 prelocalhost newdomain.comznewdomain.com:1235rrrrrr assertFalser-bypasss r(test_proxy_bypass_environment_host_match3ProxyTests.test_proxy_bypass_environment_host_match s 88  ZO Q {+, {+, {+, |,- 345 456 {+, w( 789 89: 789 /0 01  456rc[RRnURR SS5 UR U"S55 UR U"S55 URR SS5 UR U"S55 UR U"S55 UR U"S55 g)Nr*rrz*, anotherdomain.comrrrs r*test_proxy_bypass_environment_always_match5ProxyTests.test_proxy_bypass_environment_always_matchs88  Z% /0 345  Z!78 234 01  456rc[RRnURR SS5 UR U"S55 UR U"S55 UR U"S55 g)Nrrz localhost zanotherdomain.com:8888 znewdomain.com:1234 )rrrrrrrs r%test_proxy_bypass_environment_newline0ProxyTests.test_proxy_bypass_environment_newline(sb88  ZG I  ./  :;<  678r)rN) rGrHrIrJrrr rrrrKr%rrrrs!" W )7&79rrc&\rSrSrSrSrSrSrg)ProxyTests_withOrderedEnvi1cj[RUl[R"5[lgr+)rr _saved_env collections OrderedDictrEs rrProxyTests_withOrderedEnv.setUp3s** ,,. rc.UR[lgr+)r!rrrEs rr"ProxyTests_withOrderedEnv.tearDown9s __ rc~S[RS'S[RS'UR[RR S55 UR[RR S55 S[RS'S[RS'[RR 5nUR0U5 S [RS'S [RS'UR[RR S55 UR[RR S 55 UR[RR S 55 UR[RR S 55 UR[RR S55 S[RS'S[RS'[RR 5nURSUS5 g)Nno_proxyrNo_Proxy arbitrary http_proxyrrz%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z my.proxy:1234zmy.proxyzhttp://somewhereelse:3128 Http_Proxyr[) rrrrrrrrrrs r,test_getproxies_environment_prefer_lowercaseFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercase<s!# :!, : @@MN @@MN#% < #: < ..779 W%!H :!* : ?? LM ??@RST ??PQ @@LM @@MN#: < #> < ..779 0'&/Br)r!N)rGrHrIrJrrr.rKr%rrrr1s/ %Crrc\rSrSrSrSrSrSr\R"\ S5S5r \R"\ S5S5r \R"\ S5S 5r \R"\ S5S 5rS rS rS rSrSrSrSrSrSrSrSr\R6"\R:SS5S5rSrSr Sr!Sr"g)urlopen_HttpTestsiUz.Test urlopen() opening a fake http connection.cURSU-S-5 [S5nURUR5S5 URUR5S5 URUR 5S5 URUR 5S5 UR 5 g!UR 5 f=f)NsHTTP/s 200 OK Hello!http://python.org/Hello!rr^r!rr@rrrh)r-verfps r check_readurlopen_HttpTests.check_readXs hn'??@ -.B   R[[]I 6   R[[]C 0   RYY[*> ?   RZZ\3 / OO DOO s B B55CcSnURS5 [RRU5nUR UR 5U5 UR 5 g!UR 5 f=f)Nz-http://docs.python.org/library/urllib.html#OKHTTP/1.1 200 OK Hello!)r^rrr!rrrh)r-rr8s rtest_url_fragment#urlopen_HttpTests.test_url_fragmentcsX= 67 '',B   RYY[# . OO DOO s ?A%%A7cURS5 [S5nURURR5 UR 5 g!UR 5 f=f)Nr<http://www.python.org)r^r!rr8 will_closerh)r-resps rtest_willclose urlopen_HttpTests.test_willclosemsJ 67 23D OODGG.. / OO DOO s 0AA&zssl module requiredc[[SS55S/-GHn[U5nSUS3nURS5 [ U5R SS5n[ RRnURUS U35 [RRS U35 SSS5 URUS U35 [RRS U35 SSS5 [S U35nURX&R55 UR5 GM g!,(df  N=f!,(df  Nb=f!UR5 f=f) Nr!z//localhost:7777/test/HTTP/1.1 200 OK Hello.\\\contain control.*http:https:)rrangechrr^reprreplacer[r\ InvalidURLassertRaisesRegexrrr!r rrh)r-char_norschemeless_urlescaped_char_reprrSrBs r(test_url_path_with_control_char_rejected:urlopen_HttpTests.test_url_path_with_control_char_rejectedusFE!TN+tf4Gw2B+CDI++"34E3F GINN**VN3C+DEI~&678  {{}5!/5IIII!s=A E #D9.E #E .5E9 E E E EE-cURS5 SnSU-S-n[RRnUR US5 [ R RSU35 SSS5 UR US5 [ R RSU35 SSS5 [SU35nURS UR55 URS UR55 URS UR55 UR5 g!,(df  N=f!,(df  N=f!UR5 f=f) NrIz:localhost:7777?a=1 HTTP/1.1 X-injected: header TEST: 123//:8080/test/?test=az*contain control.*\\r.*(found at least . .)rMcontain control.*\\nrN   ) r^r[r\rSrTrrr!r rrh)r-rurVrSrBs r4test_url_path_with_newline_header_injection_rejectedFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejecteds% 67O';; //J''IK&&~.>'?@K'' 4KL&&/?'@AMU>"234D   S$++- 0   T4;;= 1   T4;;= 1 OO KKML OO s<,E #D0,E#E)A6E0 D>:E E EE$c2[[SS55S/-Hn[U5nSUS3nURS5 [ U5R SS5n[ RRnURUS U35 [S U35 SSS5 URUS U35 [S U35 SSS5 UR5 M g!,(df  NO=f!,(df  N4=f!UR5 f=f) NrrFrGz //localhostz/test/rIrJrKrLrMrN) rrOrPr^rQrRr[r\rSrTr!rh)r-rUrrVrWrSs r(test_url_host_with_control_char_rejected:urlopen_HttpTests.test_url_host_with_control_char_rejectedsE!TN+tf4Gw(>D&&';<E LL   OO  ED OO s",B" B"B" BB""B4c[[5R5HnURSSS9 UR [ R R5n[ RRS5 SSS5 WRR5 UR5 M g!,(df  N==f!UR5 f=f)Ns_HTTP/1.1 302 Found Location: file://guidocomputer.athome.com:/python/license Connection: close Trchttp://something) rOrmaxtriesr^rrrurvrr!rwrDrh)r-irxs rtest_redirect_limit_independent1urlopen_HttpTests.test_redirect_limit_independents~'001A MM   "&&v||'='=>"NN**+=>? ""$!2 ?>!s#)C B2;"C2 C <CCcURS5 UR[[S5 UR 5 g!UR 5 f=f)Nrr)r^rOSErrorr!rhrEs rtest_empty_socket#urlopen_HttpTests.test_empty_sockets= c    gw0B C OO DOO s ?Ac4UR[RR5n[ S5 SSS5 UR WR R5 UR UR R5 g!,(df  NY=f)Nz/file://localhost/a/file/which/doesnot/exists.py) rrruURLErrorr!rrwfilenamereasonr-es rtest_missing_localfile(urlopen_HttpTests.test_missing_localfile s_   v||44 5 E F6  ,,-  **+6 5 B  Bc[R"5upSUR[RR S5-nUR [RRU55 [U5nUR U5 SSS5 [R"U5 [R"U5 UR[RRU55 UR[RR5 [U5 SSS5 g!,(df  N=f![R"U5 [R"U5 f=f!,(df  g=f)Nzfile://localhost/rH)tempfilemkstemprRrpathseprexistsr!rDunlinkrrrrur)r-fdtmp_file tmp_fileurlfobjs rtest_file_notexists%urlopen_HttpTests.test_file_notexistss'') )H,<,cURS5 [S5nURUR5S5 URUR5S5 URUR 5S5 URUR 5S5 UR 5 g!UR 5 f=f)NHTTP/1.0 200 OK Hello!zhttp://user:pass@python.org/r4rr5r6)r-r8s rtest_userpass_inurl%urlopen_HttpTests.test_userpass_inurl8s 67 78B   R[[]I 6   R[[]C 0   RYY[*H I   RZZ\3 / OO DOO s B B//CcURS5 SnSRU5n[RRnS[ UR S55RS5-n[U5nURXCRRS55 URUR5S5 URUR5S5 URUR5U5 URUR5S 5 UR!5 g!UR!5 f=f) Nrza b:c dzhttp://{}@python.org/zAuthorization: Basic %s ASCIIzUTF-8r4rr5)r^formatr[r\r]r encodedecoder!assertInr,rr@assertNotEqualrrrh)r-userpassrfakehttp_wrapper authorizationr8s rtest_userpass_inurl_w_spaces.urlopen_HttpTests.test_userpass_inurl_w_spacesCs 67  H)00:C#{{99 :&xw'?@GGPQMB MM-)=)=)D)DW)M N   R[[]I 6   R[[]C 0    S 1   RZZ\3 / OO DOO s DD22Ec[R"S[45 [RR 5 SSS5 g!,(df  g=fNr()rr#r$rr URLopenerrEs rtest_URLopener_deprecation,urlopen_HttpTests.test_URLopener_deprecationVs3  + +R0B,C D NN $ $ &E D Ds A Ar%N)#rGrHrIrJrr9r=rCunittest skipUnlesssslrXrardrgrkrnrrryr}rrrrrrrrrrrrrrrKr%rrr1r1Us8 34"5"4345234"5" 34 5     " ", !,,  \\&..-34 &'rr1cN\rSrSrSrSrSrSrSrSr Sr S r S r S r S rg )urlopen_DataTestsi[z"Test urlopen() opening a data URL.c UR[RR5 SUlSUlSUlSUlSUlUR[RRUR 55Ul UR[RRUR55Ul UR[RRUR55Ul g)Nutest data URLs :;,%=& ö Ä sUPNG  IHDR{@sRGBIDATc```? o/IENDB`zZdata:text/plain;charset=UTF-8,test%20data%20URLs%20%3A%3B%2C%25%3D%26%20%C3%B6%20%C3%84%20zPdata:text/plain;charset=ISO-8859-1;base64,dGVzdCBkYXRhIFVSTHMgOjssJT0mIPYgxCA%3Dzdata:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7 QOjdAAAAAXNSR0IArs4c6QAAAA9JREFUCNdj%0AYGBg%2BP//PwAGAQL%2BCm8 vHgAAAABJRU5ErkJggg%3D%3D%0A%20) addCleanuprr urlcleanuprimagetext_urltext_url_base64 image_urlrr! text_url_resptext_url_base64_respimage_url_resprEs rrurlopen_DataTests.setUp^s 112;  F  (     .  ".. NN " "4== 13$($5$5 NN " "4#7#7 8%:!"//0F0Ft~~0VWrcNSHnURURU5 M! g)N)r<r@rrDrrrr)rrrs rr urlopen_DataTests.test_interface~s&GD   t114 8GrcLURURR5[RR 5 UR URR5R5SS/5 UR URR5S[[UR555 [RRS5nUR UR5R5SS/5 UR!5 g)N)z text/plainr()charsetz ISO-8859-1zcontent-lengthzdata:,)rzUS-ASCII)rrrrrrrr get_paramsrstrrrrrr!rD)r-rs rrurlopen_DataTests.test_infos d005579N9NO 22779DDF !: ; = ,,1134DE DJJ  " NN " "8 , ,,. !8 9 ;  rc<URURR5UR5 URURR5UR 5 URUR R5UR5 gr+)rrrrrrrrrEs rrurlopen_DataTests.test_geturlsp ++224dmmD 2299;   " ,,335t~~FrcURURR5R[ URR 5R 55S5UR5 gNr)rrr<rdictrrrrEs rtest_read_text urlopen_DataTests.test_read_textsZ ++00299 ##((*557 8 CEFJii QrcURURR5R[ URR 5R 55S5UR5 gr)rrr<rrrrrrEs rtest_read_text_base64'urlopen_DataTests.test_read_text_base64sY 22779@@ **//1<<> ? JL II rclURURR5UR5 gr+)rrr<rrEs rtest_read_image!urlopen_DataTests.test_read_images% ,,113TZZ@rcbUR[[RRS5 g)Nzdata:text/plainrrrrr!rEs rtest_missing_comma$urlopen_DataTests.test_missing_commas *V^^%;%;)>9 :rcDS[R-nURU5 [RR UR [R5U5nURXS5 UR[RRU5S5 [US5nUR5nUR5 UR5 URURU5 g! N!=f!UR5 f! f=f=f)N%s.2rzcopy of the file was not maderb)rrrrrr rrrrrrrr<rDr)r- second_tempr rrs r test_copyurlretrieve_FileTests.test_copysy///  ##K0++D,F,F   -*, Qi0 {369 :K& 99;D JJL D) D Ds02 DC??DDDDDDc^S/4U4SjjnS[R-nTRU5 [RR TR [R5X!5 g)Nrc>TRU[5 TRU[5 TRU[5 TRXS5 USS-US'g)Nrr )rrr) block_countblock_read_size file_size count_holderr-s r hooktester9urlretrieve_FileTests.test_reporthook..hooktestersW  ! !+s 3  ! !/3 7  ! !)S 1   [q/ :*1o1LOrr)rrrrrr r)r-rrs` rtest_reporthook%urlretrieve_FileTests.test_reporthooksVNOS 2 y///  ##K0""  & &y'7'7 8  %rc/nU4SjnUR5n[RRUR U5[ R U5 UR[U5S5 URUSSS5 g)Nc*URXU45 gr+rrrr_reports rrAurlretrieve_FileTests.test_reporthook_0_bytes..hooktester  NNK)D Err rr rrrr rrrrrr-reportr srcFileNames rtest_reporthook_0_bytes-urlretrieve_FileTests.test_reporthook_0_bytes stHN F,,. ""4#=#=k#J   j * Va( 1q)rcH/nU4SjnURS5n[RRUR U5[ R U5 UR[U5S5 URUSSS5 URUSSS5 g)Nc*URXU45 gr+r"r#s rrAurlretrieve_FileTests.test_reporthook_5_bytes..hooktesterr&rsxxxxxr rr r'r(s rtest_reporthook_5_bytes-urlretrieve_FileTests.test_reporthook_5_bytessHN F,,X6 ""4#=#=k#J   j * Va( 1q) 1q)rc/nU4SjnURSS-5n[RRUR U5[ R U5 UR[U5S5 URUSSS5 URUSSS5 URUSSS5 URUSSS5 g) Nc*URXU45 gr+r"r#s rrDurlretrieve_FileTests.test_reporthook_8193_bytes..hooktester(r&rxi rr r i r'r(s rtest_reporthook_8193_bytes0urlretrieve_FileTests.test_reporthook_8193_bytes#sHN F,,TD[9 ""4#=#=k#J   j * Va( 1t, 1t, 1t, 1t,r)rrN)r)rGrHrIrJrrrrrrrrrr+r1r8rKr%rrrrs=20 C (:*$ % * *-rrc$\rSrSrSrSrSrSrg)urlretrieve_HttpTestsi4z5Test urllib.urlretrieve() using fake http connectionscUR[RR5 UR S5 SnUR [R R5 [RR[RUS9 UR5 SSS5 g!UR5 f=f!,(df  g=f)NHTTP/1.1 200 OK Date: Wed, 02 Jan 2008 03:03:54 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e Connection: close Content-Length: 100 Content-Type: text/html; charset=iso-8859-1 FF cgr+r%)par1par2par3s r _reporthookYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.._reporthookDs r) reporthook rrrrr^rruContentTooShortErrorr r TEST_HTTP_URLrh)r-rBs r.test_short_content_raises_ContentTooShortErrorDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError7s 112     v||@@ A "**7+@+@6A+C! B A ! B As$'C),B/C/CC CcUR[RR5 UR S5 UR [R R5 [RR[R5 UR5 SSS5 g!UR5 f=f!,(df  g=f)Nr=rErEs rAtest_short_content_raises_ContentTooShortError_without_reporthookWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookNs 112    v||@@ A "**7+@+@A! B A! B As$$C&-B-C-B??C Cr%N)rGrHrIrJrrHrKrKr%rrr;r;4s?"."rr;cN\rSrSrSrSrSrSrSrSr Sr S r S r S r S rg ) QuotingTestsiaa)Tests for urllib.quote() and urllib.quote_plus() According to RFC 3986 (Uniform Resource Identifiers), to escape a character you write it as '%' + <2 character US-ASCII hex value>. The Python code of ``'%' + hex(ord())[2:]`` escapes a character properly. Case does not matter on the hex letters. The various character sets specified are: Reserved characters : ";/?:@&=+$," Have special meaning in URIs and must be escaped if not being used for their special meaning Data characters : letters, digits, and "-_.!~*'()" Unreserved and do not need to be escaped; can be, though, if desired Control characters : 0x00 - 0x1F, 0x7F Have no use in URIs so must be escaped space : 0x20 Must be escaped Delimiters : '<>#%"' Must be escaped Unwise : "{}|\^[]`" Must be escaped cSR/SQ5n[RRU5nUR XSU<SU<35 [RR U5nUR XSU<SU<35 g)Nr()ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 0123456789z_.-~using quote():  != using quote_plus(): )joinrrrr quote_plus)r- do_not_quoter s rtest_never_quoteQuotingTests.test_never_quote{suxx!)* ##L1 v6BFK M((6 v:FO QrcrUR[RRRSS5 g)NrrH)rrrr __defaults__rEs rtest_default_safeQuotingTests.test_default_safes' ++88;SArcSn[RRXS9nURXSU<SU<35 [RR UUS9nURXSU<SU<35 [RRUSS9nURXSU<SU<35 [RRSSS S 9n[RRSSS S 9nURX2SU<SU<35 [RRSSS S 9n[RRSSS S 9nURX2SU<SU<35 g) Nz<>saferSrTrUs<>uaüblatin-1ü)encodingrar()rrrrrW)r-quote_by_defaultr expects r test_safeQuotingTests.test_safesY##$4#L )66FO Q(()9.>)@ )6*F4 5##$45#A )66FO Q##Hyv#N##Hyr#J  &* +##Hyw#O##Hyr#J  &* +rc [S5Vs/sHn[U5PM nnURS5 UR[S55 SRU5nUHn[R R U5nUR[U5USU<S[U5<SU<35 [R RU5nUR[U5USU<S [U5<SU<35 M AS nS n[R R U5nURXdSU<S U<35 [R RU5nURXdSU<S U<35 gs snf) N z <>#%"{}|\^[]`rGr(rSz should be escaped to z, not rUz should be escapes to zab[]cdz ab%5B%5DcdrT) rOrPrrVrrrrrrW)r-num should_quoterr  partial_quoteexpecteds rtest_default_quoting!QuotingTests.test_default_quotingsE-2"I6ISCI 6,-CH%ww|,  D\\''-F   Yt_f#IdOV= >\\,,T2F   Yt_f#IdOV= >!  ##M2 66>G I((7 6;CVL N-7sFc H[RRS5nURU[ S5SU<S[ S5<35 [RR S5nURUSSU-5 SnUR S[ S55n[RRU5nURX1SU<SU<35 UR SS5n[RR U5nURX1SU<SU<35 g)Nr^rSrT+zusing quote_plus(): %r != +z a b cd e frU)rrrrrrWrR)r-r givenrgs rtest_quoting_spaceQuotingTests.test_quoting_spaces##C( 36 6$@ 6G IsC(**51 =CVL NrcSnSn[RRU5nURX#SU<SU<35 [RRS5nSnURX#SU<SU<35 SnSn[RRU5nURX#SU<SU<35 S nSn[RRU5nURX#SU<SU<35 g) N"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docrrT 漢%C3%BCs漢üs %A2%D8ab%FFr|s %A2ab%FFrrs rtest_unquote_to_bytes$UnquotingTests.test_unquote_to_bytess48..u5 "F, - ..~>( "F, -"..u5 "F, -  "..u5 "F, -rc*SnSn[RRU5nURX#SU<SU<35 [RRUSSS9nURX#SU<SU<35 [RRSSS9nSnURX#SU<SU<35 S nS n[RRU5nURX#SU<SU<35 S nS n[RRU5nURX#SU<SU<35 [RRUS S9nURX#SU<SU<35 S nSn[RRUSS9nURX#SU<SU<35 [RRS5nSnURX#SU<SU<35 [RRSSS9nSnURX#SU<SU<35 g)Nrubrückner_sapporo_20050930.docrrTrzbr%FCckner_sapporo_20050930.docrbr~rrz%F3%B1u�rR)rr(ignoreru漢üu漢%FCrrrrrs rtest_unquote_with_unicode(UnquotingTests.test_unquote_with_unicodes45%%e, 8>G I%%ed4%H 8>G I%%&G/8&:5 8>G I%%%e, 8>G I%%e, 8>G I%%eI%> 8>G I%%eH%= 8>G I%%n5 8>G I %%kI%F 8>G IrcrSnSn[RRU5nURX#SU<SU<35 SnSn[RRU5nURX#SU<SU<35 SnSn[RRU5nURX#SU<SU<35 g) Ns blueberryjam blueberryjamrrTsblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjrrs rtest_unquoting_with_bytes_input.UnquotingTests.test_unquoting_with_bytes_inputs%%e, 8>G I70%%e, 8>G I10%%e, 8>G Irr%N)rGrHrIrJrrrrrrrrrrrKr%rrrr.s< (*Q"ZH- N N->8ItIrrc`\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSrSrg)urlencode_TestsizTests for urlencode()c (/SQn[RRU5nUH!nURXTSU<SU<SU<35 M# UR UR S5SSU<SUR S5<35 UR S5nXFS- nXFS-nURUR5=(a UR5SU<S U<35 UR [U5S SU<S [U5<S S <35 g )zHelper method for testing different input types. 'given' must lead to only the pairs: * 1st, 1 * 2nd, 2 * 3rd, 3 Test cannot assume anything about order. Docs make no guarantee and have possible dictionary input. )z1st=1z2nd=2z3rd=3ztesting z: z not found in &r z: expected 2 '&'s; got r z%: '&' not located in proper place in z#: unexpected number of characters: rTN) rr urlencoderrrindexrisdigitr) r-rt test_typeexpect_somewherer ro amp_location on_amp_left on_amp_rights rhelp_inputtypeurlencode_Tests.help_inputtypes7''.(H MM(F#Xv7 8) c*A#V\\#%68 9||C( A-. Q./   ++-H,2F2F2H) * Vk$S[+? @rc0URSSSS.S5 g)N123)1st2nd3rdzusing dict as input typerrEs rtest_using_mapping"urlencode_Tests.test_using_mapping&s 3c=6 8rc,UR/SQS5 g)N))rr)rr)rrz*using sequence of two-item tuples as inputrrEs rtest_using_sequence#urlencode_Tests.test_using_sequence+s FH JrcSS0n[S5<S[S5<3n[RRU5nUR X#5 SS0nSn[RRU5nUR X#5 g)Nr=zkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrrrrs r test_quotingurlencode_Tests.test_quoting0sqS %cNIcN;''. (/0-''. (rcS/SQ0nS[RR[/SQ55-n[RR U5nUR X#5 [RR US5nUSHnSU-nUR X#5 M UR URS5SSURS5-5 g)Nsequence)rrrz sequence=%sTrr zExpected 2 '&'s, got %s)rrrWrrrrr)r-rtrgr values r test_dosequrlencode_Tests.test_doseq;sO,!8!8_9M!NN''. (''t4:&E"U*F MM& )' c*A2V\\#5FF HrcURS[RR055 URS[RR/55 grrrrrrEs rtest_empty_sequence#urlencode_Tests.test_empty_sequenceHs@ V\\33B78 V\\33B78rcURS[RRSS055 URS[RRSS055 g)Nza=1ar za=NonerrEs rtest_nonstring_values%urlencode_Tests.test_nonstring_valuesLsH  6 6Qx @A 6<<#9#93+#FGrchURS[RRSSS/0S55 URS[RRSSS/0S55 [R "SS/5nURS [RRSU0S55 g) Nza=1&a=2rr r Tz a=None&a=a)rr )br za=a&a=b)rrrrr"r#)r-rs rtest_nonstring_seq_values)urlencode_Tests.test_nonstring_seq_valuesPs FLL$:$:C!Q=$$OP //tSk0BDI K&&(';< //d TB Drc:SnSn[RRUSSS9nURX#5 SnSn[RRU5nURX#5 SnSn[RRUSS 9nURX#5 g) N) Á%3F=%3FrrRr %C2%A0=%C3%81%A0=%C1rbr~rrrrrs rtest_urlencode_encoding'urlencode_Tests.test_urlencode_encodingXs''' 'R (( ''. (('' 'B (rc|SnSn[RRUSSSS9nURX#5 SnSn[RRUSSSS 9nURX#5 SnS n[RRUS5nURX#5 S nS n[RRUS5nURX#5 SnS n[RRUSSS9nURX#5 S nSn[RRUSSS9nURX#5 g)NrrTrrR)doseqrdr))r)r rz %3F=1&%3F=%3Frr))r)*rz%C2%A0=42&%C2%A0=%C3%81rrbr~z%A0=42&%A0=%C1rrs rtest_urlencode_encoding_doseq-urlencode_Tests.test_urlencode_encoding_doseqks@'''T18(L (- ''t18(L (( ''t4 (-*''t4 ((''ti'H (-!''ti'H (rc8SnSn[RRU5nURX#5 [RRUS5nURX#5 SnSn[RRUS5nURX#5 g)N)$$z %A0%24=%C1%24T))r)rrz%A0%24=42&%A0%24=%C1%24rrs rtest_urlencode_bytes$urlencode_Tests.test_urlencode_bytess- ''. (''t4 (4*''t4 (rcTSn[RRUSS9nSnURX25 Sn[RRUSSS9nSnURX25 SnSn[RRUSSS9nURX25 Sn[RRUSS S 9nSnURX25 SnSn[RRUSSS S 9nSnSn[RRUSSS S 9nURX25 g) Nrz:$r`z %A0$=%C1$T)rra))r)r rz%A0$=%C1$&%A0$=13&%A0$=42rb)rard)rrardr)r-rtr rgs r&test_urlencode_encoding_safe_parameter6urlencode_Tests.test_urlencode_encoding_safe_parameters? .''D'9 (-''T'E (9,''t$'? (.''D1:(< (-''T1:(<9,''t$1:(< (rr%N)rGrHrIrJrrrrrrrrrrrrrrKr%rrrrsH@@8 J ) H9HD)&#)J )&)rrc\rSrSrSrSrSr\R"\ RS:HS5S5r \R"\ RS:HS5S 5r \R"\RS 5S 5r\R"\ RS:HS5S 5r\R"\ RS:HS5S 5r\R"\RS 5S5rSrg)Pathname_Testsiz&Test pathname2url() and url2pathname()c0[RRSSSS5nSn[RR U5nUR X#SU<SU<35 [RRU5nUR XSU<SU<35 g) Npartsofrrzparts/of/a/pathpathname2url() failed; rTzurl2pathame() failed; )rrrVrrrr url2pathname)r- expected_path expected_urlr s rrPathname_Tests.test_basics WdC@ ( ,,]; v ,0 1,,\:  -1 2rc[RRSSS5nS[RR S5-n[R RU5nURX#SU<SU<35 Un[R RU5nURX#SU<SU<35 [RRSS 5nS [RR S5-n[R RU5nURX#SU<SU<35 S n[RRS S 5n[R RU5nURX#SU<SU<35 g)Nneedszquot=ingherez needs/%s/hererrTzurl2pathname() failed; z make sure using_quotez%s/using_quotezmake+sure/using_unquotez make+sure using_unquote) rrrVrrrrrrrrs rrPathname_Tests.test_quotingsD Wj&9 6<<#5#5j#AA,,U3  &* +,,V4  &* + [-8!FLL$6$6{$CC,,U3  &* +*k?;,,U3  &* +rwin32z#test specific to Windows pathnames.c[RRnURU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S 5S 5 URU"S 5S 5 URU"S 5S5 URU"S5S5 URU"S5S5 URU"S5S5 UR [ US5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S 5S!5 URU"S"5S 5 URU"S5S5 URU"S#5S5 URU"S$5S5 /S%QnUH8nURU"[RR U55U5 M: g)&Nz \\?\C:\dirz ///C:/dirz\\?\unc\server\share\dirz//server/share/dirC:///C:C:\///C:/zC:\a\b.cz ///C:/a/b.cz C:\a\b.c\z ///C:/a/b.c/z C:\a\\b.cz ///C:/a//b.cz C:\a\b%#cz///C:/a/b%25%23cuC:\a\béz///C:/a/b%C3%A9C:\foo\bar\spam.foo///C:/foo/bar/spam.foozXX:\z \folder\test\ /folder/test/z\\folder\test\z//folder/test/z\\\folder\test\z///folder/test/z \\some\share\z //some/share/z\\some\share\a\b.cz//some/share/a/b.cu\\some\share\a\b%#céz//some/share/a/b%25%23c%C3%A9zC:/a/b.cz //?/C:/dirz//?/unc/server/share/dir)rr"r!)rrrrrIOErrorr)r-fnurlsrs rtest_pathname2url_win$Pathname_Tests.test_pathname2url_wins^^ ( ( ,-{; <=?ST D7+ FX. L)=9 N+^< N+^< M*,>? N+->? 457OP '2w/ ./A 013CD 235FG /0/B 568LM :;=\] J7 013GH L);7 679MN*C   R ; ;C @A3 Grz test specific to POSIX pathnamescX[RRnURU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S 5 g) NrHz/a/b.cz//a/b.cz ////a/b.cz///a/b.cz /////a/b.cz //////a/b.cz/a/b%#cz /a/b%25%23c)rrrrr-r$s rtest_pathname2url_posix&Pathname_Tests.test_pathname2url_posixs^^ ( ( C#& Hx0 I 4 J6 K-8 I 6rzneed os_helper.FS_NONASCIIc*[R"5n[R"5n[RR [ RXS9nUR[RR[ R5U5 gNr) sysgetfilesystemencodinggetfilesystemencodeerrorsrrrr FS_NONASCIIrrrr-rdrrs rtest_pathname2url_nonascii)Pathname_Tests.test_pathname2url_nonascii sb,,...0ll  !6!6 Y 44Y5J5JKSQrcj[RRnURU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S 5S 5 URU"S 5S 5 URU"S 5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 UR [ US5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S 5S5 URU"S!5S"5 URU"S#5S5 URU"S$5S%5 URU"S&5S'5 /S(QnUH8nURU"[RR U55U5 M: g))Nz/C:/rz///C|rrrz/C|//zC:\\z ///C|/pathzC:\pathz ///C/test/z\C\test\z ////C/test/z \\C\test\zC:/path/to/filezC:\path\to\filezC:/path/to/file/zC:\path\to\file\zC:/path/to//filezC:\path\to\\filezC|/path/to/filez/C|/path/to/filez///C|/path/to/filez///C|/foo/bar/spam.foor u///è|/z//server/path/to/filez\\server\path\to\filez////server/path/to/filez/////server/path/to/filez//localhost/C:/path/to/filez//localhost/C|/path/to/filez//localhost/path/to/filez \path\to\filez //localhost//server/path/to/filez C:/foo%2fbarz C:\foo/barz//server/share/foo%2fbarz\\server\share\foo/bar)rz \C\test\\r )rrrrrr#r)r-r$pathsrs rtest_url2pathname_win$Pathname_Tests.test_url2pathname_win'sm^^ ( ( FV, Gd+ Gd+ Hv. Gh/ L):6 L)=9 M*O< -.0DE ./1GH ./1GH -.0DE ./1EF 013GH 457OP '2}5 346RS 568TU 679UV 9:?A]^ N+]; 679UV)D   R ; ;D ABD Irc([RRnURU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 URU"S5S5 g)Nz/foo/barz //foo/barz ///foo/barz ////foo/barz//localhost/foo/bar)rrrrr)s rtest_url2pathname_posix&Pathname_Tests.test_url2pathname_posixQs{^^ ( ( J4 K+6 L):6 M*K8 12J?rc[R"5n[R"5n[RnUR [ RRU5[R5 [ RRX1US9nUR [ RRU5[R5 gr-) r.r/r0rr1rrrrrrr2s rtest_url2pathname_nonascii)Pathname_Tests.test_url2pathname_nonascii[s,,...0## 44S99;P;PQll   G 44S99;P;PQrr%N)rGrHrIrJrrrrrr.platformr&skipIfr*rr1r3r7r:r=rKr%rrr r s!0 2+60>@ H@ HD__S\\W,79797..0LMRNR 0>@&J@&JP__S\\W,79@9@..0LMRNRrr c\rSrSrSrSrSrg) Utility_Testsidz=Testcase to test the various utility functions in the urllib.chUR[RR5[5 g)zATest the urllib.request.thishost utility function returns a tupleN)rrrthishosttuplerEs r test_thishostUtility_Tests.test_thishostgs fnn557?rr%N)rGrHrIrJrrFrKr%rrrBrBds G@rrBc\rSrSrSrSr\R"\S9S5r \R"\S9S5r \R"\S9S5r Sr g ) URLopener_Testsilz4Testcase to test the open method of URLopener class.cN"SS[RR5n[R"S[ 45 UR U"5RS5S5 UR U"5RS5S5 SSS5 g!,(df  g=f)Nc\rSrSrSrSrg)8URLopener_Tests.test_quoted_open..DummyURLopeneripcU$r+r%r-rs r open_spamBURLopener_Tests.test_quoted_open..DummyURLopener.open_spamq rr%N)rGrHrIrJrOrKr%rrDummyURLopenerrLp rrRz8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrrrr#r$rr)r-rRs rtest_quoted_open URLopener_Tests.test_quoted_openos V^^55  + +K"$%   ^-22#%%5 7   ^-22>@9 ;%%%s A B B$)categoryc[R"5n[R"US9up#[R "U5 S[ RRU5-n[ RR5RU5upVUR[RRU5[RRU55 SSS5 g!,(df  g=f)N)dirzfile:)rtemp_dirrrrrDrrrrretrieverrnormcase)r-tmpdirrtmpfilefileurlr_s rtest_urlopener_retrieve_file,URLopener_Tests.test_urlopener_retrieve_file~s    !V"**v6KB HHRL ; ;G DDG ..224==gFKH   RWW--h79I9I'9R S " ! !s C C)) C7c"SnURS5 URUR5 [RR 5R U5up#UR[RRU5SS5 g)Nzhttp://www.python.org/file.txtr<r z.txt) r^rrhrrrrZrrrsplitext)r-rrr_s rtest_urlopener_retrieve_remote.URLopener_Tests.test_urlopener_retrieve_remotesg. 67 (nn..099#>  ))(3A6?rcF"SS[RR5nSHnUR[[RR U5 UR[[RR5R U5 UR[[RR5RU5 UR[U"5R U5 UR[U"5RU5 M g)Nc\rSrSrSrSrg).DummyURLopenericU$r+r%rNs ropen_local_fileLURLopener_Tests.test_local_file_open..DummyURLopener.open_local_filerQrr%N)rGrHrIrJrjrKr%rrrRrhrSrrR)zlocal_file://examplezlocal-file://example)rrrrrr!rrZ)r-rRrs rtest_local_file_open$URLopener_Tests.test_local_file_opens V^^55 DC   gv~~'='=s C   gv~~'?'?'A'F'F L   gv~~'?'?'A'J'JC P   g~'7'<' ;$$.@ATBT$$.@A@B@$$.@A GB GrrIc$\rSrSrSrSrSrSrg) RequestTestsiz&Unit tests for urllib.request.Request.c[RRnU"S5nURUR 5S5 U"S05nURUR 5S5 g)Nr@rPOST)rrRequestr get_methodr-rsrs rtest_default_values RequestTests.test_default_valuess[..((12 ++-u5126 ++-v6rc[RRnU"SSS9nURURS5 URUR 5S5 U"S0SS9nURURS5 URUR 5S5 U"SSS9nURUR 5S5 SUlURUR 5S5 g)Nr@HEAD)methodr)rrrsrrzrtrus rtest_with_method_arg!RequestTests.test_with_method_args..((1&A 0 ++-v612fE 0 ++-v61%@ ++-u5 ++-v6rr%N)rGrHrIrJrrvr{rKr%rrrprps07 7rrp__main__)NNrj)8r urllib.parserurllib.request urllib.error http.clientr[ email.messagerr:r unittest.mockrrr test.supportrrrtest.support.testcaserrr ImportErrorr.rbase64r r"has_gethostnameSkipTestrrr!rr^rr`rlTestCaserrrr1rrr;rNrrr rBrIrprGmainr%rrrsA "&(1  $$   9 ::  & /,^