a 5êdg¬ã@s6ddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlZz ddlZWneyzdZYn0ddlZddlZddlmZmZddlmZddlZdd„Zdad4dd „Zd d „Zd5d d„ZGdd„deƒZGdd„deƒZ Gdd„de j!ƒZ"Gdd„de j!ƒZ#Gdd„de j!ƒZ$Gdd„de j!ee ƒZ%Gdd„de j!ƒZ&Gdd„de j!ƒZ'Gdd „d e j!eƒZ(Gd!d"„d"e j!ƒZ)Gd#d$„d$e j!ƒZ*Gd%d&„d&e j!ƒZ+Gd'd(„d(e j!ƒZ,Gd)d*„d*e j!ƒZ-Gd+d,„d,ee j!ƒZ.Gd-d.„d.e j!ƒZ/Gd/d0„d0e j!ƒZ0Gd1d2„d2e j!ƒZ1e2d3kr2e  3¡dS)6éN)Úpatch)Úsupport)Ú url2pathnameÚ pathname2url)Ú b64encodecCs4tt|ƒƒdd… ¡}t|ƒdkr,d|}d|S)Nééz0%sú%)ÚhexÚordÚupperÚlen)ÚcharZhex_repr©rú,/usr/local/lib/python3.9/test/test_urllib.pyÚ hexescapes rcCsN|durtjj|d}nts(tƒ}|ant}|dur>| |¡S| ||¡SdS)N)Úproxies)ÚurllibÚrequestÚFancyURLopenerÚ _urlopenerÚopen)ÚurlÚdatarÚopenerrrrÚurlopen$s rcCs<t dtf¡tj ¡WdƒS1s.0YdS)Nz8FancyURLopener style of invoking requests is deprecated.)rÚcheck_warningsÚDeprecationWarningrrrrrrrr4s ÿÿrFcs:G‡fdd„dtjƒ‰G‡‡fdd„dtjjƒ‰|ˆ_ˆS)Ncs@eZdZdZ‡fdd„Zdd„Zd dd„Zdd d „Zd d „ZdS)zfakehttp..FakeSocketrcs |ˆ_dS©N)Úbuf©Úselfr©ÚFakeHTTPConnectionrrÚsendall?sz$fakehttp..FakeSocket.sendallc_s|jd7_|S)Nr)Úio_refs)r!ÚargsÚkwdsrrrÚmakefileBsz%fakehttp..FakeSocket.makefileNcSs|jr dStj ||¡S©Nó)ÚclosedÚioÚBytesIOÚread)r!Zamtrrrr.Fsz!fakehttp..FakeSocket.readcSs|jr dStj ||¡Sr))r+r,r-Úreadline)r!Úlengthrrrr/Ksz%fakehttp..FakeSocket.readlinecSs(|jd8_|jdkr$tj |¡dS)Nrr)r%r,r-Úclose©r!rrrr1Ps z"fakehttp..FakeSocket.close)N)N) Ú__name__Ú __module__Ú __qualname__r%r$r(r.r/r1rr"rrÚ FakeSocket<s    r6cs(eZdZdZ‡fdd„Z”r$dd„ZdS)z$fakehttp..FakeHTTPConnectionNcsˆ|jƒ|_|jt|ƒ_dSr)ÚfakedataÚsockÚtypeZfakesockr2)r6rrÚconnectZs z,fakehttp..FakeHTTPConnection.connectcSsdSrrr2rrrr1csz*fakehttp..FakeHTTPConnection.close)r3r4r5rr:r1r)r6Ú mock_closerrr#Us r#)r,r-ÚhttpÚclientÚHTTPConnectionr7)r7r;r)r#r6r;rÚfakehttp;sr?c@seZdZddd„Zdd„ZdS)Ú FakeHTTPMixinFcCs"t||d}tjj|_|tj_dS)N©r;)r?r<r=r>Ú_connection_class)r!r7r;Zfake_http_classrrrr?ks  zFakeHTTPMixin.fakehttpcCs|jtj_dSr)rBr<r=r>r2rrrÚ unfakehttppszFakeHTTPMixin.unfakehttpN)F)r3r4r5r?rCrrrrr@js r@c@seZdZdd„Zdd„ZdS)Ú FakeFTPMixincCs&Gdd„dtƒ}tjj|_|tj_dS)Nc@s&eZdZd dd„Zdd„Zdd„ZdS) z,FakeFTPMixin.fakeftp..FakeFtpWrapperNTcSsdSrr)r!ÚuserÚpasswdÚhostÚportÚdirsÚtimeoutZ persistentrrrÚ__init__wsz5FakeFTPMixin.fakeftp..FakeFtpWrapper.__init__cSs t ¡dfS)Nr)r,r-)r!Úfiler9rrrÚretrfile{sz5FakeFTPMixin.fakeftp..FakeFtpWrapper.retrfilecSsdSrrr2rrrr1~sz2FakeFTPMixin.fakeftp..FakeFtpWrapper.close)NT)r3r4r5rKrMr1rrrrÚFakeFtpWrappervs ÿ rN)ÚobjectrrÚ ftpwrapperÚ_ftpwrapper_class)r!rNrrrÚfakeftpus zFakeFTPMixin.fakeftpcCs|jtj_dSr)rQrrrPr2rrrÚ unfakeftp„szFakeFTPMixin.unfakeftpN)r3r4r5rRrSrrrrrDtsrDc@sŒeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!S)"Úurlopen_FileTestscCsptd|jjdƒ|_ttjdƒ}z| |j¡W| ¡n | ¡0tj|_ t j   |j ¡|_ td|j ƒ|_dS)Nztest_urllib: %s ÚasciiÚwbúfile:%s)ÚbytesÚ __class__r3ÚtextrrÚTESTFNÚwriter1ÚpathnamerÚparseÚquoteÚquoted_pathnamerÚ returned_obj)r!ÚfrrrÚsetUps ÿ zurlopen_FileTests.setUpcCs|j ¡t tj¡dSr)rar1ÚosÚremoverr[r2rrrÚtearDowns zurlopen_FileTests.tearDowncCs&dD]}| t|j|ƒd|¡qdS)N) r.r/Ú readlinesÚfilenor1ÚinfoÚgeturlÚgetcodeÚ__iter__ú/object returned by urlopen() lacks %s attribute)Ú assertTrueÚhasattrra©r!ÚattrrrrÚtest_interface¢s ÿÿz urlopen_FileTests.test_interfacecCs| |j|j ¡¡dSr)Ú assertEqualrZrar.r2rrrÚ test_readªszurlopen_FileTests.test_readcCs,| |j|j ¡¡| d|j ¡d¡dS)Nr*zKcalling readline() after exhausting the file did not return an empty string)rsrZrar/r2rrrÚ test_readline­sÿzurlopen_FileTests.test_readlinecCs4|j ¡}| t|ƒdd¡| |d|jd¡dS)Nrz.readlines() returned the wrong number of linesrz"readlines() returned improper text)rargrsr rZ)r!Z lines_listrrrÚtest_readlines³s  ÿÿz urlopen_FileTests.test_readlinescCs:|j ¡}| |td¡| t |t|jƒ¡|jd¡dS)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text) rarhÚassertIsInstanceÚintrsrdr.r rZ)r!Zfile_numrrrÚ test_filenoºs  ÿzurlopen_FileTests.test_filenocCs|j ¡dSr)rar1r2rrrÚ test_closeÁszurlopen_FileTests.test_closecCs| |jjtjj¡dSr)rwraZheadersÚemailÚmessageÚMessager2rrrÚ test_headersÆszurlopen_FileTests.test_headerscCs| |jj|j¡dSr)rsrarr`r2rrrÚtest_urlÉszurlopen_FileTests.test_urlcCs| |jj¡dSr)Ú assertIsNoneraÚstatusr2rrrÚ test_statusÌszurlopen_FileTests.test_statuscCs| |j ¡tjj¡dSr)rwrarir{r|r}r2rrrÚ test_infoÏszurlopen_FileTests.test_infocCs| |j ¡|j¡dSr)rsrarjr`r2rrrÚ test_geturlÒszurlopen_FileTests.test_geturlcCs| |j ¡¡dSr)r€rarkr2rrrÚ test_getcodeÕszurlopen_FileTests.test_getcodecCs|jD]}| ||j¡qdSr)rarsrZ)r!ÚlinerrrÚ test_iterØs zurlopen_FileTests.test_itercCs| ttjjd|j¡dS)Nz./)Ú assertRaisesÚ ValueErrorrrrr]r2rrrÚtest_relativelocalfileász(urlopen_FileTests.test_relativelocalfileN)r3r4r5rcrfrrrtrurvryrzr~rr‚rƒr„r…r‡rŠrrrrrTˆs   rTc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú ProxyTestscCs6t ¡|_ttjƒD]}d| ¡vr|j |¡qdS)NÚproxy)rZEnvironmentVarGuardÚenvÚlistrdÚenvironÚlowerÚunset)r!Úkrrrrcçs  zProxyTests.setUpcCs|j ¡|`dSr)rÚ__exit__r2rrrrfïs zProxyTests.tearDowncCsp|j dd¡tj ¡}| d|d¡|j dd¡| tj d¡¡| tj d¡¡| tj d¡¡dS)NÚNO_PROXYÚ localhostÚnoú0localhost, anotherdomain.com, newdomain.com:1234úanotherdomain.comúanotherdomain.com:8888únewdomain.com:1234)rÚsetrrÚgetproxies_environmentrsrnÚproxy_bypass_environment©r!rrrrÚ+test_getproxies_environment_keep_no_proxiesôs z6ProxyTests.test_getproxies_environment_keep_no_proxiesc Csˆzh|j dd¡tj ¡}| d|d¡|j dd¡tj ¡}| d|¡W|j d¡|j d¡n|j d¡|j d¡0dS)NÚ HTTP_PROXYúhttp://somewhere:3128r<ZREQUEST_METHODÚGET)rr›rrrœrsÚ assertNotInr‘ržrrrÚtest_proxy_cgi_ignoreÿs   ÿ z ProxyTests.test_proxy_cgi_ignorecCsÞtjj}|j dd¡| |dƒ¡| |dƒ¡| |dƒ¡| |dƒ¡| |dƒ¡| |dƒ¡| |d ƒ¡| |d ƒ¡| |d ƒ¡| |d ƒ¡| |d ƒ¡| |dƒ¡| |dƒ¡| |dƒ¡dS)Nr”z8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr•Z LocalHostZ LOCALHOSTz .localhostršz.newdomain.com:1234z foo.d.o.tzd.o.tr™z.anotherdomain.com:8888zwww.newdomain.com:1234Z prelocalhostú newdomain.comznewdomain.com:1235©rrrrr›rnÚ assertFalse©r!ZbypassrrrÚ(test_proxy_bypass_environment_host_match s$ÿz3ProxyTests.test_proxy_bypass_environment_host_matchcCsntjj}|j dd¡| |dƒ¡| |dƒ¡|j dd¡| |dƒ¡| |dƒ¡| |dƒ¡dS)Nr”Ú*r¥ršz*, anotherdomain.comr˜r¦r¨rrrÚ*test_proxy_bypass_environment_always_matchsz5ProxyTests.test_proxy_bypass_environment_always_matchcCsDtjj}|j dd¡| |dƒ¡| |dƒ¡| |dƒ¡dS)Nr”r—z localhost zanotherdomain.com:8888 znewdomain.com:1234 )rrrrr›r§r¨rrrÚ%test_proxy_bypass_environment_newline(sÿz0ProxyTests.test_proxy_bypass_environment_newlineN) r3r4r5rcrfrŸr¤r©r«r¬rrrrr‹ås   r‹c@s$eZdZdd„Zdd„Zdd„ZdS)ÚProxyTests_withOrderedEnvcCstj|_t ¡t_dSr)rdrÚ _saved_envÚ collectionsÚ OrderedDictr2rrrrc3szProxyTests_withOrderedEnv.setUpcCs |jt_dSr)r®rdrr2rrrrf9sz"ProxyTests_withOrderedEnv.tearDowncCsdtjd<dtjd<| tj d¡¡| tj d¡¡dtjd<dtjd<tj ¡}| i|¡d tjd<d tjd<| tj d¡¡| tj d ¡¡| tj d ¡¡| tj d ¡¡| tj d¡¡dtjd<dtjd<tj ¡}| d|d¡dS)NÚZno_proxyr•ZNo_ProxyZ arbitraryZ http_proxyr¡r z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z my.proxy:1234zmy.proxyzhttp://somewhereelse:3128Z Http_Proxyr<) rdrr§rrrrœrsrnržrrrÚ,test_getproxies_environment_prefer_lowercase<s&           zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r3r4r5rcrfr²rrrrr­1sr­c@seZdZdd„Zdd„Zdd„Ze ed¡dd „ƒZ e ed¡d d „ƒZ e ed¡d d „ƒZ e ed¡dd„ƒZ dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Ze ejd&d'¡d(d)„ƒZd*d+„Zd,d-„Zd.d/„Ze ed¡d0d1„ƒZ d2S)3Úurlopen_HttpTestscCsv| d|d¡zTtdƒ}| | ¡d¡| | ¡d¡| | ¡d¡| | ¡d¡W| ¡n | ¡0dS)NsHTTP/s 200 OK Hello!úhttp://python.org/óHello!r*éÈ©r?rrsr/rjrkrC)r!ÚverÚfprrrÚ check_readXszurlopen_HttpTests.check_readcCsFd}| d¡z(tj |¡}| | ¡|¡W| ¡n | ¡0dS)Nz-http://docs.python.org/library/urllib.html#OKóHTTP/1.1 200 OK Hello!)r?rrrrsrjrC)r!rr¹rrrÚtest_url_fragmentcs   z#urlopen_HttpTests.test_url_fragmentcCs<| d¡z"tdƒ}| |jj¡W| ¡n | ¡0dS)Nr»úhttp://www.python.org)r?rrnr¹Z will_closerC)r!ÚresprrrÚtest_willclosems  z urlopen_HttpTests.test_willclosezssl module requiredc CsttddƒƒdgD]ø}t|ƒ}d|›d}| d¡zÊt|ƒ dd¡}tjj}|  |d |›¡"t j   d |›¡Wdƒn1sŠ0Y|  |d |›¡"t j   d |›¡Wdƒn1sÎ0Yt d |›ƒ}|  || ¡¡W| ¡q| ¡0qdS) Nré!éz//localhost:7777/testú/óHTTP/1.1 200 OK Hello.ú\ú\\úcontain control.*úhttp:úhttps:)rŽÚrangeÚchrr?ÚreprÚreplacer<r=Ú InvalidURLÚassertRaisesRegexrrrr£rjrC)r!Úchar_norÚschemeless_urlÚescaped_char_reprrÍr¾rrrÚ(test_url_path_with_control_char_rejectedus$   ÿ0 ÿ0z:urlopen_HttpTests.test_url_path_with_control_char_rejectedcCsø| d¡d}d|d}zÎtjj}| |d¡"tj d|›¡Wdƒn1sX0Y| |d¡"tj d|›¡Wdƒn1s–0Ytd|›ƒ}| d |  ¡¡| d |  ¡¡| d |  ¡¡W|  ¡n |  ¡0dS) NrÃz:localhost:7777?a=1 HTTP/1.1 X-injected: header TEST: 123ú//ú:8080/test/?test=az*contain control.*\\r.*(found at least . .)rÇúcontain control.*\\nrÈú ú Ú ) r?r<r=rÍrÎrrrr£rjrC)r!rGrÐrÍr¾rrrÚ4test_url_path_with_newline_header_injection_rejecteds   ÿ00zFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejectedc CsìttddƒƒdgD]Ò}t|ƒ}d|›d}| d¡z¤t|ƒ dd¡}tjj}|  |d |›¡t d |›ƒWdƒn1s†0Y|  |d |›¡t d |›ƒWdƒn1sÆ0YW|  ¡q|  ¡0qdS) NrrÀrÁz //localhostz/test/rÃrÄrÅrÆrÇrÈ) rŽrÉrÊr?rËrÌr<r=rÍrÎrrC)r!rÏrrÐrÑrÍrrrÚ(test_url_host_with_control_char_rejectedªs   ÿ,.z:urlopen_HttpTests.test_url_host_with_control_char_rejectedcCs²| d¡d}d|d}zˆtjj}| |d¡td|›ƒWdƒn1sT0Y| |d¡td|›ƒWdƒn1sŽ0YW| ¡n | ¡0dS) NrÃzlocalhost X-injected: header rÓrÔzcontain control.*\\rrÇrÕrÈ)r?r<r=rÍrÎrrC)r!rGrÐrÍrrrÚ4test_url_host_with_newline_header_injection_rejected»s  ÿ,.zFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejectedcCs| d¡dS)Ns0.9©rºr2rrrÚ test_read_0_9Êszurlopen_HttpTests.test_read_0_9cCs| d¡dS)Ns1.0rÜr2rrrÚ test_read_1_0Ïszurlopen_HttpTests.test_read_1_0cCs| d¡dS)Ns1.1rÜr2rrrÚ test_read_1_1Òszurlopen_HttpTests.test_read_1_1cCs8|jdddz| ttd¡W| ¡n | ¡0dS)NsÎHTTP/1.1 401 Authentication Required 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-Type: text/html; charset=iso-8859-1 TrAr´©r?rˆÚOSErrorrrCr2rrrÚtest_read_bogusÕs ûz!urlopen_HttpTests.test_read_boguscCsf|jdddzHd}| tjj|¡tdƒWdƒn1sB0YW| ¡n | ¡0dS)NsöHTTP/1.1 302 Found 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 Location: file://guidocomputer.athome.com:/python/license Connection: close Content-Type: text/html; charset=iso-8859-1 TrAzRedirection to url 'file:r´)r?rÎrÚerrorÚ HTTPErrorrrC)r!ÚmsgrrrÚtest_invalid_redirectâsú(z'urlopen_HttpTests.test_invalid_redirectc CsNttƒjƒD]<}|jdddz| tjjtd¡W|  ¡q |  ¡0q dS)Ns_HTTP/1.1 302 Found Location: file://guidocomputer.athome.com:/python/license Connection: close TrAúhttp://something) rÉrZmaxtriesr?rˆrrãrärrC)r!ÚirrrÚtest_redirect_limit_independentòsý ÿz1urlopen_HttpTests.test_redirect_limit_independentcCs4| d¡z| ttd¡W| ¡n | ¡0dS)Nr*rçràr2rrrÚtest_empty_sockets z#urlopen_HttpTests.test_empty_socketcCsV| tjj¡}tdƒWdƒn1s,0Y| |jj¡| |jj¡dS)Nz/file://localhost/a/file/which/doesnot/exists.py) rˆrrãÚURLErrorrrnÚ exceptionÚfilenameÚreason©r!ÚerrrÚtest_missing_localfile s&z(urlopen_HttpTests.test_missing_localfilec Csàt ¡\}}d| tjjd¡}z\| tj |¡¡t|ƒ}| |¡Wdƒn1s\0YWt  |¡t  |¡nt  |¡t  |¡0|  tj |¡¡|  t jj¡t|ƒWdƒn1sÒ0YdS)Nzfile://localhost/rÂ)ÚtempfileÚmkstemprÌrdÚpathÚseprnÚexistsrr1Úunlinkr§rˆrrãrë)r!ÚfdZtmp_fileZ tmp_fileurlZfobjrrrÚtest_file_notexistss  *  ÿ  z%urlopen_HttpTests.test_file_notexistscCsZd}| tjj¡}t|ƒWdƒn1s00Y| |jj¡| |jj ¡dS)Nz ftp:///path© rˆrrãrërr§rìrírnrî)r!Z test_ftp_urlrðrrrÚtest_ftp_nohosts &z!urlopen_HttpTests.test_ftp_nohostcCsV| tjj¡}tdƒWdƒn1s,0Y| |jj¡| |jj ¡dS)Nz.ftp://localhost/a/file/which/doesnot/exists.pyrúrïrrrÚtest_ftp_nonexisting%s&z&urlopen_HttpTests.test_ftp_nonexistingZ MAXFTPCACHErcCsH| ¡z0tj ddddg¡tjjd<tdƒW| ¡n | ¡0dS)NrEÚpassr•éÚtestzftp://localhost)rRrrrPZftpcacherrSr2rrrÚtest_ftp_cache_pruning+s  z(urlopen_HttpTests.test_ftp_cache_pruningcCsn| d¡zTtdƒ}| | ¡d¡| | ¡d¡| | ¡d¡| | ¡d¡W| ¡n | ¡0dS)NóHTTP/1.0 200 OK Hello!zhttp://user:pass@python.org/rµr*r¶r·)r!r¹rrrÚtest_userpass_inurl4s z%urlopen_HttpTests.test_userpass_inurlcCs°| d¡z–d}d |¡}tjj}dt| d¡ƒ d¡}t|ƒ}|  ||j  d¡¡|  |  ¡d¡|  |  ¡d¡|  | ¡|¡|  | ¡d ¡W| ¡n | ¡0dS) Nrza b:c dzhttp://{}@python.org/zAuthorization: Basic %s ÚASCIIzUTF-8rµr*r¶)r?Úformatr<r=r>rÚencodeÚdecoderÚassertInrrsr/ZassertNotEqualrjrkrC)r!ZuserpassrZfakehttp_wrapperZ authorizationr¹rrrÚtest_userpass_inurl_w_spaces?s  ÿz.urlopen_HttpTests.test_userpass_inurl_w_spacescCs<t dtf¡tj ¡Wdƒn1s.0YdS©Nr±)rrrrrÚ URLopenerr2rrrÚtest_URLopener_deprecationRsz,urlopen_HttpTests.test_URLopener_deprecationc Csvt ¡}t dtf¡L| t¡"tjj dd|dWdƒn1sJ0YWdƒn1sh0YdS)Nr±zhttps://localhostz/nonexistent/path)ZcafileÚcontext) ÚsslZcreate_default_contextrrrrˆr‰rrr)r!r rrrÚtest_cafile_and_contextVs  ÿz)urlopen_HttpTests.test_cafile_and_contextN)!r3r4r5rºr¼r¿ÚunittestÚ skipUnlessr rÒrÙrÚrÛrÝrÞrßrârærérêrñrùrûrürrOrrrrrr rrrrrr³Us:               r³c@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Úurlopen_DataTestscCs`| tjj¡d|_d|_d|_d|_d|_tj  |j¡|_ tj  |j¡|_ tj  |j¡|_ dS)Nutest data URLs :;,%=& ö Ä sU‰PNG  IHDR{@èÝsRGB®ÎéIDAT×c```øÿÿ?þ o/IEND®B`‚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Ú urlcleanuprZÚimageÚtext_urlÚtext_url_base64Ú image_urlrÚ text_url_respÚtext_url_base64_respÚimage_url_respr2rrrrccsÿÿÿÿÿzurlopen_DataTests.setUpcCs&dD]}| t|j|ƒd|¡qdS)N)r.r/rgr1rirjrkrlrm)rnrorrprrrrr‚s ÿÿz urlopen_DataTests.test_interfacecCst| |j ¡tjj¡| |j ¡ ¡ddg¡| |j  ¡dt t |j ƒƒ¡| t j d¡ ¡ ¡ddg¡dS)N)z text/plainr±)Úcharsetz ISO-8859-1zcontent-lengthzdata:,)rzUS-ASCII)rwrrir{r|r}rsrÚ get_paramsrÚstrr rrrrr2rrrrƒŠsÿ ÿÿzurlopen_DataTests.test_infocCs@| |j ¡|j¡| |j ¡|j¡| |j ¡|j¡dSr)rsrrjrrrrrr2rrrr„“s  ÿzurlopen_DataTests.test_geturlcCs0| |j ¡ t|j ¡ ¡ƒd¡|j¡dS©Nr)rsrr.rÚdictrirrZr2rrrÚtest_read_text™s ÿÿz urlopen_DataTests.test_read_textcCs0| |j ¡ t|j ¡ ¡ƒd¡|j¡dSr)rsrr.rrrirrZr2rrrÚtest_read_text_base64s ÿþz'urlopen_DataTests.test_read_text_base64cCs| |j ¡|j¡dSr)rsrr.rr2rrrÚtest_read_image¢sz!urlopen_DataTests.test_read_imagecCs| ttjjd¡dS)Nzdata:text/plain©rˆr‰rrrr2rrrÚtest_missing_comma¥sz$urlopen_DataTests.test_missing_commacCs| ttjjd¡dS)Nzdata:;base64,Cg=r#r2rrrÚtest_invalid_base64_data¨sz*urlopen_DataTests.test_invalid_base64_dataN) r3r4r5rcrrrƒr„r r!r"r$r%rrrrr`s rc@sfeZdZdd„Zdd„Zdd„Zddd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dS)Úurlretrieve_FileTestsc Cs†| tjj¡g|_| tj¡d|_z>t tjdƒ}|  |j¡|  ¡Wz |  ¡Wq‚Yq‚0nz |  ¡Wn Yn00dS)Nstesting urllib.urlretrieverV) rrrrÚ tempFilesÚregisterFileForCleanUprr[rZrr\r1)r!ÚFILErrrrc°s     ÿzurlretrieve_FileTests.setUpcCs,|jD] }zt |¡WqYq0qdSr)r'rdre)r!ZeachrrrrfÈs zurlretrieve_FileTests.tearDowncCsHtj |¡}z| d¡Wnty6t d¡‚Yn0dtj  |¡S)Nzutf-8z!filePath is not encodable to utf8z file://%s) rdrôÚabspathrÚUnicodeEncodeErrorrZSkipTestrrr)r!ZfilePathrrrÚconstructLocalFileUrlÎs   z+urlretrieve_FileTests.constructLocalFileUrlr*c Cstt ¡\}}zF| |¡t |d¡}| |¡| ¡Wz | ¡WqpYqp0nz | ¡Wn Yn00|S)NrV)ròrór(rdÚfdopenr\r1)r!rZnewFdZ newFilePathZnewFilerrrÚcreateNewTempFileÖs     ÿz'urlretrieve_FileTests.createNewTempFilecCs|j |¡dSr)r'Úappend)r!ZfileNamerrrr(æsz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj dtj¡}| |dtj¡| |dtjj d¡dS)NrWrrzFdid not get an email.message.Message instance as second returned value) rrÚ urlretrieverr[rsrwr{r|r})r!ÚresultrrrÚ test_basicés ÿz urlretrieve_FileTests.test_basicc Cs¶dtj}| |¡tj | tj¡|¡}| ||d¡| t j   |¡d¡t |dƒ}z.|  ¡}| ¡Wz | ¡Wq¤Yq¤0nz | ¡Wn Yn00| |j|¡dS)Nú%s.2rzcopy of the file was not madeÚrb)rr[r(rrr0r,rsrnrdrôrörr.r1rZ)r!Ú second_tempr1r)rZrrrÚ test_copyòs$   ÿÿ  ÿzurlretrieve_FileTests.test_copycsBdgf‡fdd„ }dtj}ˆ |¡tj ˆ tj¡||¡dS)NrcsHˆ |t¡ˆ |t¡ˆ |t¡ˆ ||d¡|dd|d<dS)Nrr)rwrxrs)Ú block_countÚblock_read_sizeÚ file_sizeZ count_holderr2rrÚ hooktesters    z9urlretrieve_FileTests.test_reporthook..hooktesterr3)rr[r(rrr0r,)r!r:r5rr2rÚtest_reporthooks   þz%urlretrieve_FileTests.test_reporthookcCsXg}|fdd„}| ¡}tj | |¡tj|¡| t|ƒd¡| |ddd¡dS)NcSs| |||f¡dSr©r/©r7r8r9Z_reportrrrr:szAurlretrieve_FileTests.test_reporthook_0_bytes..hooktesterrrr© r.rrr0r,rr[rsr ©r!Úreportr:Z srcFileNamerrrÚtest_reporthook_0_bytess ÿz-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd„}| d¡}tj | |¡tj|¡| t|ƒd¡| |ddd¡| |ddd¡dS)NcSs| |||f¡dSrr<r=rrrr:"szAurlretrieve_FileTests.test_reporthook_5_bytes..hooktestersxxxxxrrérr>r?rrrÚtest_reporthook_5_bytess  ÿz-urlretrieve_FileTests.test_reporthook_5_bytescCsšg}|fdd„}| dd¡}tj | |¡tj|¡| t|ƒd¡| |ddd¡| |ddd ¡| |ddd ¡| |ddd ¡dS) NcSs| |||f¡dSrr<r=rrrr:0szDurlretrieve_FileTests.test_reporthook_8193_bytes..hooktesteróxi érrri r>r?rrrÚtest_reporthook_8193_bytes+s ÿz0urlretrieve_FileTests.test_reporthook_8193_bytesN)r*)r3r4r5rcrfr,r.r(r2r6r;rArCrFrrrrr&­s   r&c@seZdZdd„Zdd„ZdS)Úurlretrieve_HttpTestsc Cs|| tjj¡| d¡dd„}| tjj¡:ztjjt j |dW|  ¡n |  ¡0Wdƒn1sn0YdS)NóÑHTTP/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 cSsdSrr)Zpar1Zpar2Zpar3rrrÚ _reporthookLszYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.._reporthook)Z reporthook© rrrrr?rˆrãÚContentTooShortErrorr0rZ TEST_HTTP_URLrC)r!rIrrrÚ.test_short_content_raises_ContentTooShortError?s  ÿzDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc Csp| tjj¡| d¡| tjj¡6ztj t j ¡W|  ¡n |  ¡0Wdƒn1sb0YdS)NrHrJr2rrrÚAtest_short_content_raises_ContentTooShortError_without_reporthookVs  zWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r3r4r5rLrMrrrrrG<srGc@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Ú QuotingTestscCsVd gd¢¡}tj |¡}| ||d||f¡tj |¡}| ||d||f¡dS)Nr±)ÚABCDEFGHIJKLMNOPQRSTUVWXYZÚabcdefghijklmnopqrstuvwxyzÚ 0123456789z_.-~úusing quote(): %r != %rúusing quote_plus(): %r != %r)Újoinrr^r_rsÚ quote_plus)r!Z do_not_quoter1rrrÚtest_never_quoteƒs  ÿ  ÿzQuotingTests.test_never_quotecCs| tjjjdd¡dS)NrrÂ)rsrr^r_Ú __defaults__r2rrrÚtest_default_safeszQuotingTests.test_default_safecCsîd}tjj||d}| ||d||f¡tjj||d}| ||d||f¡tjj|dd}| ||d||f¡tjjdddd }tjjddd d }| ||d||f¡tjjddd d }tjjddd d }| ||d||f¡dS) Nz<>©ÚsaferRrSs<>uaübúlatin-1õü)ÚencodingrZr±óü)rr^r_rsrU)r!Zquote_by_defaultr1ÚexpectrrrÚ test_safe”s> ÿÿÿÿ ÿÿÿÿÿzQuotingTests.test_safec Csèdd„tdƒDƒ}| d¡| tdƒ¡d |¡}|D]\}tj |¡}| t|ƒ|d|t|ƒ|f¡tj  |¡}| t|ƒ|d|t|ƒ|f¡q8~d }d }tj |¡}| ||d ||f¡tj  |¡}| ||d ||f¡dS) NcSsg|] }t|ƒ‘qSr)rÊ)Ú.0ÚnumrrrÚ ´r*z5QuotingTests.test_default_quoting..é z <>#%"{}|\^[]`rÁr±z1using quote(): %s should be escaped to %s, not %sz6using quote_plus(): %s should be escapes to %s, not %szab[]cdz ab%5B%5DcdrRrS) rÉr/rÊrTrr^r_rsrrU)r!Z should_quoterr1Z partial_quoteÚexpectedrrrÚtest_default_quoting±s8     þÿ   þÿ  ÿ  ÿz!QuotingTests.test_default_quotingcCs°tj d¡}| |tdƒd|tdƒf¡tj d¡}| |dd|¡d}| dtdƒ¡}tj |¡}| ||d||f¡| dd¡}tj |¡}| ||d||f¡dS)NrÖrRú+zusing quote_plus(): %r != +z a b cd e frS)rr^r_rsrrUrÌ)r!r1Úgivenr_rrrÚtest_quoting_spaceÍs&  ÿ ÿ  ÿ   ÿzQuotingTests.test_quoting_spacecCsX| tj d¡d¡| tj dd¡d¡| tj d¡d¡| tj dd¡d¡dS)Nzalpha+beta gammazalpha%2Bbeta+gammargzalpha+beta+gammasalpha+beta gammaó+)rsrr^rUr2rrrÚtest_quoting_plusàsÿÿÿÿzQuotingTests.test_quoting_pluscCsfd}d}tj |¡}| ||d||f¡|jttjj|ddtj |¡}| ||d||f¡dS)Nó¢Øabÿú %A2%D8ab%FFrRr[©r]z"using quote_from_bytes(): %r != %r)rr^r_rsrˆÚ TypeErrorÚquote_from_bytes©r!rhr_r1rrrÚtest_quote_bytesìs  ÿÿ ÿÿzQuotingTests.test_quote_bytescCs(d}d}tj |¡}| ||d||f¡tjj|ddd}| ||d||f¡d}d}tjj|dd}| ||d||f¡d}d }tj |¡}| ||d||f¡d}|jttjj|ddd}d }tjj|dd d}| ||d||f¡d}d }tjj|dd d}| ||d||f¡dS)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFrR©r]Úerrorsrmr[rnõ漢字ú%E6%BC%A2%E5%AD%97z%3F%3FrÌz%26%2328450%3B%26%2323383%3BÚxmlcharrefreplace)rr^r_rsrˆr+rqrrrÚtest_quote_with_unicodeüsT  ÿ ÿ ÿ  ÿÿ ÿ ÿ ÿ ÿz$QuotingTests.test_quote_with_unicodecCsbd}d}tjj|dd}| ||d||f¡d}d}tjj|ddd }| ||d||f¡dS) Nu¢Ø ÿz %A2%D8+%FFr[rnrSu ab漢字 cdz ab%3F%3F+cdrÌrs)rr^rUrsrqrrrÚtest_quote_plus_with_unicode&s ÿ ÿ ÿz)QuotingTests.test_quote_plus_with_unicodeN) r3r4r5rVrXr`rfrirkrrrxryrrrrrNis  *rNc@sLeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dS)ÚUnquotingTestscCsÔg}tdƒD]f}tt|ƒƒ}t|ƒ}tj |¡}| ||d||f¡tj |¡}| ||d||f¡| |¡q d  |¡}~tj |¡}| |  d¡dd|¡|  t t ftjjd¡|  t t ftjjd¡dS) Né€úusing unquote(): %r != %rúusing unquote_plus(): %r != %rr±r rz/using unquote(): not all characters escaped: %sr)rÉrrÊrr^ÚunquotersÚ unquote_plusr/rTÚcountrˆroÚAttributeError)r!Z escape_listrbrhr_r1Z escape_stringrrrÚtest_unquoting=s2    ÿ ÿÿ   ÿÿzUnquotingTests.test_unquotingcCs>d}|}tj |¡}| ||d||f¡d}|}tj |¡}| ||d||f¡d}|}tj |¡}| ||d||f¡d}t|dƒ}tj |¡}| ||d||f¡d}t|dƒ}tj |¡}| ||d||f¡d}t|dƒ}tj |¡}| ||d||f¡| ttftjjd¡| ttftjjd¡dS)Nz%xabr|z%xr rUú"using unquote_to_bytes(): %r != %rr) rr^r~rsrXÚunquote_to_bytesrˆrorrqrrrÚtest_unquoting_badpercentTsL  ÿ  ÿ  ÿ   ÿ   ÿ   ÿz(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj |¡}| ||d||f¡dS)Nz%Ab%eAs«êrƒ©rr^r„rsrqrrrÚtest_unquoting_mixed_casexs ÿÿz(UnquotingTests.test_unquoting_mixed_casecCsXdtdƒ}d}tj |¡}| ||d||f¡tj |¡}| ||d||f¡dS)Nzab%sdÚcZabcdrRr})rrr^r~rsrrqrrrÚtest_unquoting_partss   ÿ  ÿz#UnquotingTests.test_unquoting_partscCs\d}|}tj |¡}| ||d||f¡| dd¡}tj |¡}| ||d||f¡dS)Nzare+there+spaces...r|rgrÖr})rr^r~rsrÌrrqrrrÚtest_unquoting_pluss  ÿ   ÿz"UnquotingTests.test_unquoting_pluscCs¨d}d}tj |¡}| ||d||f¡tj d¡}d}| ||d||f¡d}d}tj |¡}| ||d||f¡d}d}tj |¡}| ||d||f¡dS) Nú"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docrƒõ æ¼¢%C3%BCs漢üs %A2%D8ab%FFrls %A2Øab%FFr†rqrrrÚtest_unquote_to_bytes™s> ÿÿ ÿÿ ÿÿ ÿÿz$UnquotingTests.test_unquote_to_bytescCsxd}d}tj |¡}| ||d||f¡tjj|ddd}| ||d||f¡tjjddd}d}| ||d||f¡d}d }tj |¡}| ||d||f¡d }d }tj |¡}| ||d||f¡tjj|d d }| ||d||f¡d }d}tjj|dd }| ||d||f¡tj d¡}d}| ||d||f¡tjjddd}d}| ||d||f¡dS)Nr‹ubrückner_sapporo_20050930.docr|rszbr%FCckner_sapporo_20050930.docr[rnrvruz%F3%B1u�rÌ)rtr±ÚignorerŒu漢üuæ¼¢%FC©rr^r~rsrqrrrÚtest_unquote_with_unicode¸sb  ÿ ÿÿ ÿ  ÿ  ÿ ÿ ÿ  ÿ ÿz(UnquotingTests.test_unquote_with_unicodecCs‚d}d}tj |¡}| ||d||f¡d}d}tj |¡}| ||d||f¡d}d}tj |¡}| ||d||f¡dS)Ns blueberryjamZ blueberryjamr|sblÃ¥bærsyltetøyublÃ¥bærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublÃ¥bærsyltetøjrrqrrrÚtest_unquoting_with_bytes_inputòs$  ÿ  ÿ  ÿz.UnquotingTests.test_unquoting_with_bytes_inputN) r3r4r5r‚r…r‡r‰rŠrrr‘rrrrrz6s$   :rzc@sleZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„ZdS)Úurlencode_Testsc Cs¾gd¢}tj |¡}|D]}| ||d|||f¡q| | d¡dd|| d¡f¡| d¡}||d}||d}| | ¡oŒ| ¡d||f¡| t |ƒdd |t |ƒdf¡dS) N)z1st=1z2nd=2z3rd=3ztesting %s: %s not found in %sú&rz#testing %s: expected 2 '&'s; got %srz1testing %s: '&' not located in proper place in %séz5testing %s: unexpected number of characters: %s != %s) rr^Ú urlencoderrsr€ÚindexrnÚisdigitr ) r!rhZ test_typeZexpect_somewherer1reZ amp_locationZ on_amp_leftZ on_amp_rightrrrÚhelp_inputtype s4  ÿÿ ÿÿ   ÿÿ  þÿzurlencode_Tests.help_inputtypecCs| ddddœd¡dS)NÚ1Ú2Ú3)Ú1stÚ2ndÚ3rdzusing dict as input type©r˜r2rrrÚtest_using_mapping,sÿz"urlencode_Tests.test_using_mappingcCs| gd¢d¡dS)N))rœr™)rrš)ržr›z*using sequence of two-item tuples as inputrŸr2rrrÚtest_using_sequence1s ÿz#urlencode_Tests.test_using_sequencecCs\ddi}dtdƒtdƒf}tj |¡}| ||¡ddi}d}tj |¡}| ||¡dS)Nr“ú=z%s=%szkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrr^r•rsrqrrrÚ test_quoting6s   zurlencode_Tests.test_quotingcCsŽdgd¢i}dtj tgd¢ƒ¡}tj |¡}| ||¡tj |d¡}|dD]}d|}| ||¡qR| | d¡dd| d¡¡dS)NZsequence)r™ršr›z sequence=%sTr“rzExpected 2 '&'s, got %s)rr^rUrr•rsrr€)r!rhr_r1ÚvaluerrrÚ test_doseqAs     ÿzurlencode_Tests.test_doseqcCs,| dtj i¡¡| dtj g¡¡dSr ©rsrr^r•r2rrrÚtest_empty_sequenceNsz#urlencode_Tests.test_empty_sequencecCs4| dtj ddi¡¡| dtj ddi¡¡dS)Nza=1Úarza=Noner¦r2rrrÚtest_nonstring_valuesRsz%urlencode_Tests.test_nonstring_valuescCsh| dtj dddgid¡¡| dtj dddgid¡¡t ddg¡}| d tj d|id¡¡dS) Nza=1&a=2r¨rrTz a=None&a=a)r¨r)Úbrza=a&a=b)rsrr^r•r¯r°r rrrÚtest_nonstring_seq_valuesVsÿÿz)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd}| ||¡d}d}tj |¡}| ||¡d}d}tjj|dd }| ||¡dS) N©)õ õÃú%3F=%3FrrÌrsú %C2%A0=%C3%81ú%A0=%C1r[rn©rr^r•rsrqrrrÚtest_urlencode_encoding^s   z'urlencode_Tests.test_urlencode_encodingcCsäd}d}tjj|dddd}| ||¡d}d}tjj|dddd }| ||¡d}d }tj |d¡}| ||¡d }d }tj |d¡}| ||¡d}d }tjj|ddd}| ||¡d }d}tjj|ddd}| ||¡dS)Nr¬r¯TrrÌ)Údoseqr]rt))r­)rr®z %3F=1&%3F=%3Frsr°))r­)é*r®z%C2%A0=42&%C2%A0=%C3%81r±r[rnz%A0=42&%A0=%C1r²rqrrrÚtest_urlencode_encoding_doseqqs8 ÿ  ÿ    z-urlencode_Tests.test_urlencode_encoding_doseqcCs`d}d}tj |¡}| ||¡tj |d¡}| ||¡d}d}tj |d¡}| ||¡dS)N©)ó $óÁ$z %A0%24=%C1%24T))r¸)rµr¹z%A0%24=42&%A0%24=%C1%24r²rqrrrÚtest_urlencode_bytes–s   z$urlencode_Tests.test_urlencode_bytescCsÞd}tjj|dd}d}| ||¡d}tjj|ddd}d}| ||¡d}d}tjj|ddd}| ||¡d}tjj|dd d }d}| ||¡d}d}tjj|ddd d }d}d}tjj|ddd d }| ||¡dS) Nr·z:$rYz %A0$=%C1$T)r´rZ))r¸)r¹é rµz%A0$=%C1$&%A0$=13&%A0$=42r[)rZr])r´rZr]r²)r!rhr1r_rrrÚ&test_urlencode_encoding_safe_parameter¤s:    ÿ  ÿ ÿz6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r3r4r5r˜r r¡r£r¥r§r©r«r³r¶rºr¼rrrrr’ s   %r’c@sPeZdZdd„Zdd„Ze ejdkd¡dd„ƒZ e ejdkd ¡d d „ƒZ d S) ÚPathname_TestscCs^tj dddd¡}d}tj |¡}| ||d||f¡tj |¡}| ||d||f¡dS)NÚpartsZofr¨rôzparts/of/a/pathúpathname2url() failed; %s != %szurl2pathame() failed; %s != %s)rdrôrTrrrrsr)r!Z expected_pathZ expected_urlr1rrrr2Ïs ÿÿ ÿÿzPathname_Tests.test_basiccCsàtj ddd¡}dtj d¡}tj |¡}| ||d||f¡|}tj  |¡}| ||d||f¡tj dd¡}d tj d¡}tj |¡}| ||d||f¡d }tj d d ¡}tj  |¡}| ||d||f¡dS) NZneedszquot=ingÚherez needs/%s/herer¿zurl2pathname() failed; %s != %sz make sureZ using_quotez%s/using_quotezmake+sure/using_unquotez make+sureZ using_unquote) rdrôrTrr^r_rrrsrrqrrrr£Üs> ÿÿ ÿÿ ÿÿ ÿÿzPathname_Tests.test_quotingÚwin32z*test specific to the nturl2path functions.cCsXd}d}tj |¡}| ||d||f¡d}d}tj |¡}| ||d||f¡dS)Nz \\?\C:\dirz ///C:/dirr¿z\\?\unc\server\share\dirz/server/share/dir)rrrrsrqrrrÚ test_prefixes÷s  ÿÿ ÿÿzPathname_Tests.test_prefixesz.test specific to the urllib.url2path function.cCsbd}d}|D]&}tj |¡}| ||d||f¡q d}d}tj |¡}| ||d||f¡dS)N)z/C:/z///C:/z/C|//úC:\z/urllib.request..url2pathname() failed; %s != %sz ///C|/pathzC:\pathz.urllib.request.url2pathname() failed; %s != %s)rrrrs)r!rhr_rr1rrrÚ test_ntpath s" ÿÿ ÿÿzPathname_Tests.test_ntpathN) r3r4r5r2r£rrÚsysÚplatformrÂrÄrrrrr½Ìs  ÿ  ÿr½c@seZdZdd„ZdS)Ú Utility_TestscCs| tj ¡t¡dSr)rwrrZthishostÚtupler2rrrÚ test_thishostszUtility_Tests.test_thishostN)r3r4r5rÉrrrrrÇsrÇc@sPeZdZdd„Zejeddd„ƒZejeddd„ƒZejeddd „ƒZ d S) ÚURLopener_TestscCsnGdd„dtjjƒ}t dtf¡8| |ƒ d¡d¡| |ƒ d¡d¡Wdƒn1s`0YdS)Nc@seZdZdd„ZdS)z8URLopener_Tests.test_quoted_open..DummyURLopenercSs|Srr©r!rrrrÚ open_spam'szBURLopener_Tests.test_quoted_open..DummyURLopener.open_spamN)r3r4r5rÌrrrrÚDummyURLopener&srÍz8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr rrrrsr)r!rÍrrrÚtest_quoted_open%s ÿÿ ÿÿ ÿþz URLopener_Tests.test_quoted_open)ÚcategorycCs†t ¡j}tj|d\}}t |¡dtj |¡}tj  ¡  |¡\}}|  tj   |¡tj   |¡¡Wdƒn1sx0YdS)N)Údirzfile:)rZtemp_dirròrórdr1rrrr ÚretrieversrôÚnormcase)r!ZtmpdirrøZtmpfileZfileurlríÚ_rrrÚtest_urlopener_retrieve_file4s   z,URLopener_Tests.test_urlopener_retrieve_filecCsJd}| d¡| |j¡tj ¡ |¡\}}| tj   |¡dd¡dS)Nzhttp://www.python.org/file.txtr»rz.txt) r?rrCrrr rÑrsrdrôÚsplitext)r!rrírÓrrrÚtest_urlopener_retrieve_remote>s   z.URLopener_Tests.test_urlopener_retrieve_remotecCs„Gdd„dtjjƒ}dD]f}| ttjj|¡| ttj ¡j|¡| ttj ¡j|¡| t|ƒj|¡| t|ƒj|¡qdS)Nc@seZdZdd„ZdS)z.DummyURLopenercSs|SrrrËrrrÚopen_local_fileJszLURLopener_Tests.test_local_file_open..DummyURLopener.open_local_fileN)r3r4r5r×rrrrrÍIsrÍ)zlocal_file://examplezlocal-file://example)rrr rˆrárrrÑ)r!rÍrrrrÚtest_local_file_openFsz$URLopener_Tests.test_local_file_openN) r3r4r5rÎrZignore_warningsrrÔrÖrØrrrrrÊ"s    rÊc@seZdZdd„Zdd„ZdS)Ú RequestTestscCs>tjj}|dƒ}| | ¡d¡|diƒ}| | ¡d¡dS)Nr½r¢ZPOST)rrÚRequestrsÚ get_method©r!rÚrrrrÚtest_default_valuesWs  z RequestTests.test_default_valuescCs”tjj}|ddd}| |jd¡| | ¡d¡|didd}| |jd¡| | ¡d¡|ddd}| | ¡d¡d|_| | ¡d¡dS)Nr½ZHEAD)Úmethodr¢)rrrÚrsrÞrÛrÜrrrÚtest_with_method_arg^s  z!RequestTests.test_with_method_argN)r3r4r5rÝrßrrrrrÙTsrÙc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚURL2PathNameTestscCs4| tdƒd¡| tdƒd¡| tdƒd¡dS)Nz///C|úC:ú///C:z///C|/rérsrr2rrrÚtest_converting_drive_letternsz.URL2PathNameTests.test_converting_drive_lettercCs$| tdƒd¡| tdƒd¡dS)Nz ///C/test/z \\\C\test\z ////C/test/z \\C\test\rãr2rrrÚ$test_converting_when_no_drive_letterssz6URL2PathNameTests.test_converting_when_no_drive_lettercCs| tdƒd¡dS)Nz///C|/foo/bar/spam.fooúC:\foo\bar\spam.foorãr2rrrÚtest_simple_comparexs ÿz%URL2PathNameTests.test_simple_comparecCs| ttd¡dS)Nu///è|/)rˆÚIOErrorrr2rrrÚtest_non_ascii_drive_letter|sz-URL2PathNameTests.test_non_ascii_drive_lettercCs*gd¢}|D]}| tt|ƒƒ|¡q dS)N)ráz \\\C\test\\ræ)rsrr©r!Z list_of_pathsrôrrrÚtest_roundtrip_url2pathnamesz-URL2PathNameTests.test_roundtrip_url2pathnameN)r3r4r5rärårçrérërrrrràls ràc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚPathName2URLTestscCs$| tdƒd¡| tdƒd¡dS)Nrárârérsrr2rrrrä‰sz.PathName2URLTests.test_converting_drive_lettercCs4| tdƒd¡| tdƒd¡| tdƒd¡dS)Nz\\\folder\test\ú/////folder/test/z\\folder\test\z////folder/test/z \folder\test\z /folder/test/rír2rrrrås ÿ ÿ ÿz6PathName2URLTests.test_converting_when_no_drive_lettercCs| tdƒd¡dS)Nræú///C:/foo/bar/spam.foorír2rrrrç•s ÿz%PathName2URLTests.test_simple_comparecCs| ttd¡dS)NzXX:\)rˆrèrr2rrrÚtest_long_drive_letter™sz(PathName2URLTests.test_long_drive_lettercCs*gd¢}|D]}| tt|ƒƒ|¡q dS)N)rârîrï)rsrrrêrrrÚtest_roundtrip_pathname2urlœsz-PathName2URLTests.test_roundtrip_pathname2urlN)r3r4r5rärårçrðrñrrrrrì‡s rìÚ__main__)NN)F)4Ú urllib.parserZurllib.requestZ urllib.errorZ http.clientr<Z email.messager{r,rZ unittest.mockrrÿrrdr Ú ImportErrorrÅròZ nturl2pathrrÚbase64rr¯rrrrr?rOr@rDZTestCaserTr‹r­r³rr&rGrNrzr’r½rÇrÊrÙràrìr3ÚmainrrrrÚsb        / ]L$ M-NTDN2