a zee@sHddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdd gfd d gfd d gfdd gfddgfdddgfdddgfdgfdgfdgfddgfddgfddgfd dgfd!d"gfd#d$d%gfd&d'd(gfd)d*gfd+d,gfd-d.gfd/d0gfgZ difdifdifdddgifd dd gifd d dgifdd dgifdd d1gifdd2gd3gdfdd d4d5gifdifdifdifdddgifdddgifdddgifd ddgifd!dd6gifd#d7gd8gd"fd&dd9d:gifd)d;d1gifd+d dgifgZ Gd?d@d@ej Z GdAdBdBej Z GdCdDdDej ZedEkrDedS)FNhttp://a/b/c/d;p?q#fhttp://a/b/c/d;p?qhttp://a/b/c/d&z&&=)rrz=a)rar)rrza=z&a=brbz a=a+b&b=b+cra br b cza=1&a=2r1r2&s&&=)rrs=a)rar)rrsa=s&a=brbs a=a+b&b=b+cra brb csa=1&a=2r1r2;a=b);ar a=a+b;b=b+c)r a b;b=b c;a=b);ar a=a+b;b=b+c)r a b;b=b cr r rrrrrrrr r"r$r&r(c@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[S)\UrlParseTestCasecCs`tj|}||||j|j|j|j|j|j f}|||tj |}|||||| tj| }|| | |||||j|j||j|j||j|j||j|j||j|j||j |j ||j |j ||j |j ||j|j||j|jtj|}||||j|j|j|j|j f}|||tj|}|||||| tj| }|| | |||||j|j||j|j||j|j||j|j||j |j ||j |j ||j |j ||j|j||j|jdSN)urllibparseurlparse assertEqualschemenetlocpathparamsqueryfragment urlunparsegeturlusernamepasswordhostnameporturlsplit urlunsplit)selfurlparsedsplitresulttZresult2Zresult3rCF/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_urlparse.pycheckRoundtripsIsV               z UrlParseTestCase.checkRoundtripscCsdtD]Z\}}tjj|dd}|||d|dd|D}tjj|dd}|||d|qdS)NTkeep_blank_valuesError parsing %rcSsg|]}t|dr|qS)len.0vrCrCrD rz-UrlParseTestCase.test_qsl..F)parse_qsl_test_casesr+r, parse_qslr.)r=origexpectrAexpect_without_blanksrCrCrDtest_qsl|s zUrlParseTestCase.test_qslcshtD]^\}tjj|dd}||d|fddD}tjj|dd}|||d|qdS)NTrFrHcs&i|]}t|dr||qS)rrJrLrSrCrD sz,UrlParseTestCase.test_qs..F)parse_qs_test_casesr+r,parse_qsr.)r=rRrArTrCrVrDtest_qss  zUrlParseTestCase.test_qscsHgd}ddfdd|D}||D]\}}}||||q*dS)N))zfile:///tmp/junk.txt)filer /tmp/junk.txtrrr)r[rr\rr)zimap://mail.python.org/mbox1)imapmail.python.org/mbox1rrr)r]r^r_rr)z1mms://wms.sys.hinet.net/cts/Drama/09006251100.asf)mmswms.sys.hinet.net/cts/Drama/09006251100.asfrrr)r`rarbrr)znfs://server/path/to/file.txt)nfsserver/path/to/file.txtrrr)rcrdrerr)z0svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/)svn+ssh svn.zope.org/repos/main/ZConfig/trunk/rrr)rfrgrhrr)z)git+ssh://git@github.com/user/project.git)git+sshgit@github.com/user/project.gitrrr)rirjrkrrcSs8|ddtdd|dDtdd|dDfS)Nrasciicss|]}|dVqdSrlNencoderMxrCrCrD rzDUrlParseTestCase.test_roundtrips.._encode..rIcss|]}|dVqdSrmrnrprCrCrDrrrrotuplerBrCrCrD_encodes z1UrlParseTestCase.test_roundtrips.._encodecsg|] }|qSrCrCrprwrCrDrOrz4UrlParseTestCase.test_roundtrips..rE)r= str_cases bytes_casesr>r?r@rCrxrDtest_roundtripss z UrlParseTestCase.test_roundtripsc sgd}ddfdd|D}d}d}||f}||f}||fD]L\}}|D]>} |D]4\} } } | | } | f| } | f| } || | | qVqNqBdS)N))z://www.python.org)www.python.orgrrrr)r}rrr)z://www.python.org#abc)r}rrrabc)r}rrr~)z://www.python.org?q=abc)r}rrq=abcr)r}rrr)z://www.python.org/#abc)r}/rrr~)r}rrr~)z://a/b/c/d;p?q#f)rz/b/c/dpqf)rz/b/c/d;prrcSs8|ddtdd|dDtdd|dDfS)Nrrlcss|]}|dVqdSrmrnrprCrCrDrrrzIUrlParseTestCase.test_http_roundtrips.._encode..rIcss|]}|dVqdSrmrnrprCrCrDrrrrsrtrvrCrCrDrws z6UrlParseTestCase.test_http_roundtrips.._encodecsg|] }|qSrCrCrprxrCrDrOrz9UrlParseTestCase.test_http_roundtrips..)httphttps)httphttpsry) r=rzr{Z str_schemesZ bytes_schemesZ str_testsZ bytes_testsZschemesZ test_casesr/r>r?r@rCrxrDtest_http_roundtripss  z%UrlParseTestCase.test_http_roundtripsc CsR|||f}|tj|||dd|D}\}}}|tj|||dS)NcSsg|]}|dqSrlrnrprCrCrDrOsz.UrlParseTestCase.checkJoin..)r.r+r,urljoin) r=baseZrelurlexpectedZstr_componentsZbytes_componentsZbasebZrelurlbZ expectedbrCrCrD checkJoins  zUrlParseTestCase.checkJoincCs`gd}dd|D}||D]<}|tjtj|||tjtj||qdS)N)Pythonz./Pythonx-newscheme://foo.com/stuffzx://yzx:/yzx:/rcSsg|]}|dqSrrnrprCrCrDrOrz7UrlParseTestCase.test_unparse_parse..)r.r+r,r<r;r5r-)r=rzr{urCrCrDtest_unparse_parses  z#UrlParseTestCase.test_unparse_parsecCs|tdd|tdd|tdd|tdd|tdd|td d |td d |td d|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|td d|td!d"|td#d$|td%d$|td&d|td'd(|td)d*|td+d,|td-d.|td/d0|td1d"|td2d|td3d4|td5d6dS)7Ng:hghttp://a/b/c/g./gg/http://a/b/c/g//g http://a/g//ghttp://gg?yhttp://a/b/c/g?yg?y/./xhttp://a/b/c/g?y/./x#shttp://a/b/c/d;p?q#sg#shttp://a/b/c/g#sg#s/./xhttp://a/b/c/g#s/./xg?y#shttp://a/b/c/g?y#sg;xhttp://a/b/c/g;xg;x?y#shttp://a/b/c/g;x?y#s. http://a/b/c/./.. http://a/b/../../g http://a/b/g../.. http://a/../../../../grrg.http://a/b/c/g..ghttp://a/b/c/.gg..http://a/b/c/g....ghttp://a/b/c/..g./../g./g/.g/./hhttp://a/b/c/g/hg/../hhttp://a/b/c/h)r RFC1808_BASEr=rCrCrD test_RFC1808s>zUrlParseTestCase.test_RFC1808cCs|tjdddS)Nzmailto:1337@example.org)mailtorz1337@example.orgrrrr.r+r,r-rrCrCrD test_RFC2368szUrlParseTestCase.test_RFC2368cCs|tdd|tdd|tdd|tdd|tdd|td d |td d |td d|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd |td!d |td"d|td#t|td$d%|td&d'|td(d)|td*d+|td,d|td-d|td.d/|td0d1|td2d3|td4d5|td6d7|td8d9|td:d;|tdNrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr g;x=1/./yhttp://a/b/c/g;x=1/y g;x=1/../yhttp://a/b/c/yrrg?y/../xhttp://a/b/c/g?y/../xrrg#s/../xhttp://a/b/c/g#s/../x)r RFC2396_BASErrCrCrD test_RFC2396sFzUrlParseTestCase.test_RFC2396cCs|tdd|tdd|tdd|tdd|tdd|td d |td d |td d|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|td d!|td"d!|td#d$|td%d&|td'd&|td(d |td)d |td)d |td*d |td+d |td,d |td-d.|td/d0|td1d2|td3d4|td5d$|td6d |td7d8|td9d:|td;d<|td=d>|td?d@|tdAdB|tdCdD|tdEdF|tdGd|dHdddS)IN?yzhttp://a/b/c/d;p?yz;xzhttp://a/b/c/;xrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrz ../../../gz ../../../../gz/./gz/../grrrrrrrrrrrrrrrrrrrrrrrrrrhttp:gzhttp://a/b/c/de)r RFC3986_BASErrCrCrD test_RFC3986Hs\zUrlParseTestCase.test_RFC3986cCsX|tdd|tdd|tdd|tdd|tdd|tdd |td d |td d |tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd|tdd |tdd|td d |td!d"|td#d$|tdd|tdd|td%d|td&d|td'd|d(dd(|d)dd|d)d*d*|d+d,d-|d.d,d/|d0dd1|d2dd3|td4d5td6|d7d8d9|d:d8d;|d7dd?|dd8d=|d@dAdAdS)BNrrrhttp:rrrrrrrrrrzhttp://a/b/c/d?yrrrrrrrrrrrrrrrrrrrrrzhttp:?yzhttp:g?yz http:g?y/./xzhttp:///rz http://a/./gzsvn://pathtorepo/dir1Zdir2zsvn://pathtorepo/dir2zsvn+ssh://pathtorepo/dir1zsvn+ssh://pathtorepo/dir2zws://a/bzws://a/gz wss://a/bz wss://a/grfooz/foozhttp://a/b/c/d/e/z ../../f/g/zhttp://a/b/c/f/g/zhttp://a/b/c/d/ezhttp://a/b/f/g/z /../../f/g/z http://a/f/g/z ../../f/gzhttp://a/b/c/f/grr )r SIMPLE_BASErrCrCrD test_urljoinssTzUrlParseTestCase.test_urljoinscsgd}ddfdd|D}||D].\}}}tj|}||j|jf||fq*gd}dd|D}||D]}|ttjj|qxdS)N))z http://Test.python.org:5432/foo/test.python.org8)zhttp://12.34.56.78:5432/foo/ 12.34.56.78r)zhttp://[::1]:5432/foo/::1r)zhttp://[dead:beef::1]:5432/foo/ dead:beef::1r)zhttp://[dead:beef::]:5432/foo/ dead:beef::r)z:http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/'dead:beef:cafe:5417:affe:8fa3:deaf:feedr)z http://[::12.34.56.78]:5432/foo/ ::12.34.56.78r)z%http://[::ffff:12.34.56.78]:5432/foo/::ffff:12.34.56.78r)zhttp://Test.python.org/foo/rN)zhttp://12.34.56.78/foo/rN)zhttp://[::1]/foo/rN)zhttp://[dead:beef::1]/foo/rN)zhttp://[dead:beef::]/foo/rN)z5http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/rN)zhttp://[::12.34.56.78]/foo/rN)z http://[::ffff:12.34.56.78]/foo/rN)zhttp://Test.python.org:/foo/rN)zhttp://12.34.56.78:/foo/rN)zhttp://[::1]:/foo/rN)zhttp://[dead:beef::1]:/foo/rN)zhttp://[dead:beef::]:/foo/rN)z6http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/rN)zhttp://[::12.34.56.78]:/foo/rN)z!http://[::ffff:12.34.56.78]:/foo/rNcSs"|dd|dd|dfS)NrrlrIrsrnrvrCrCrDrwsz.UrlParseTestCase.test_RFC2732.._encodecsg|] }|qSrCrCrprxrCrDrOrz1UrlParseTestCase.test_RFC2732..)zhttp://::12.34.56.78]/zhttp://[::1/foo/zftp://[::1/foo/bad]/badzhttp://[::1/foo/bad]/badzhttp://[::ffff:12.34.56.78cSsg|]}|dqSrrnrprCrCrDrOr)r+r,r-r.r9r: assertRaises ValueError)r=rzr{r>r9r:Z urlparsedZ invalid_urlrCrxrD test_RFC2732s   zUrlParseTestCase.test_RFC2732c sddddddddtd d ftd d fg }d d fdd|D}||D]R\}}}tj|}|||||||f||j|||j|qFdS)N)zhttp://python.org#fraghttp://python.orgfrag)rrr)zhttp://python.org/#fraghttp://python.org/r)rrr)zhttp://python.org/?q#fraghttp://python.org/?qr)rrr)zhttp://python.org/p#fragzhttp://python.org/pr)http://python.org/p?qrrrrrcSst|dd|DS)Ncss|]}|dVqdSrmrnrprCrCrDrrrzCUrlParseTestCase.test_urldefrag.._encode..)typervrCrCrDrwsz0UrlParseTestCase.test_urldefrag.._encodecsg|] }|qSrCrCrprxrCrDrOrz3UrlParseTestCase.test_urldefrag..) rrr+r, urldefragr.r6r>r4)r=rzr{r>defragrrArCrxrDtest_urldefrags&  zUrlParseTestCase.test_urldefragcCsTtjd}||jd||jdtjd}||jd||jddS)Nz,http://[FE80::822a:a8ff:fe49:470c%tESt]:1234zfe80::822a:a8ff:fe49:470c%tEStz%[FE80::822a:a8ff:fe49:470c%tESt]:1234s,http://[FE80::822a:a8ff:fe49:470c%tESt]:1234sfe80::822a:a8ff:fe49:470c%tESts%[FE80::822a:a8ff:fe49:470c%tESt]:1234)r+r,r;r.r9r0)r=rrCrCrDtest_urlsplit_scoped_IPv6s   z*UrlParseTestCase.test_urlsplit_scoped_IPv6cCsd}tj|}||jd||jd||jd||jd||jd||j d||j d||j d||j d|| dd|ddd }tj|}||jd||jd ||jd||jd ||jd||j d ||j d ||j d||j d|| |d}tj|}||jd||jd||jd||jd ||jd||j d||j d ||j d||j d|| |d}tj|}||jd||jd||jd||jd||jd||j d||j d||j d||j d|| dd|ddd}tj|}||jd||jd||jd||jd||jd||j d||j d||j d||j d|| |d}tj|}||jd||jd||jd||jd||jd||j d ||j d||j d||j d|| |d!}tj|}|td"|j Wdn1s0YdS)#NzHTTP://WWW.PYTHON.ORG/doc/#fragrzWWW.PYTHON.ORGz/doc/rrr}z7http://User:Pass@www.python.org:080/doc/?query=yes#fragUser:Pass@www.python.org:080z query=yesZUserZPassPzChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag(User@example.com:Pass@www.python.org:080zUser@example.comsHTTP://WWW.PYTHON.ORG/doc/#fragrsWWW.PYTHON.ORGs/doc/rsfragwww.python.orgs7http://User:Pass@www.python.org:080/doc/?query=yes#fragsUser:Pass@www.python.org:080s query=yessUsersPasssChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#frags(User@example.com:Pass@www.python.org:080sUser@example.coms%HTTP://WWW.PYTHON.ORG:65536/doc/#fragz out of range)r+r,r;r.r/r0r1r3r4r7r8r9r:r6assertRaisesRegexr)r=r>rrCrCrDtest_urlsplit_attributes s         z)UrlParseTestCase.test_urlsplit_attributescCsd}tj|}||jd||jd||jd||jd||jd||j d||j d||j d||j d|| dd}tj|}||jd ||jd ||jd ||jd ||jd ||j d||j d||j d ||j d|| dd}d}tdD]4}tjj||d}||jd|| dqLdS)NzQhttp ://www.python .org /java script: alert('msg ')/?query = something#frag mentrr}z/javascript:alert('msg')/zquery=somethingr4zGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentsQhttp ://www.python .org /java script: alert('msg ')/?query = something#frag mentrrs/javascript:alert('msg')/squery=somethingfragmentsGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentzNhttp://www.python.org/java script: alert('msg ')/?query = something#frag mentzht tprsr/)r+r,r;r.r/r0r1r3r4r7r8r9r:r6range)r=r>rr/_rCrCrD!test_urlsplit_remove_unsafe_bytesgs<   z2UrlParseTestCase.test_urlsplit_remove_unsafe_bytesc CsdD]}tjjtjjfD]}dD]}|j|||d~d|}d|}|r^|d}|d}||}||j||t |j Wdn1s0YWdq 1s0Yq qqdS)z Check handling of invalid ports.)FT)rz1.5z-1Z0x10)bytesr,r:zwww.example.net:zhttp://rlN) r+r,r;r-subTestror.r0rrr:)r=rr,r:r0r>rrCrCrDtest_attributes_bad_ports   z)UrlParseTestCase.test_attributes_bad_portcCsd}tj|}||jd||jd||jd||jd||jd|| |tj |}||jd||jd||jd||jd||jd|| |d}tj|}||jd||jd||jd||jd||jd|| |tj |}||jd||jd||jd||jd||jd|| |dS)Nz0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15rs0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15r) r+r,r;r.r0r7r8r9r:r6r-)r=ZurirrCrCrDtest_attributes_without_netlocs<    z/UrlParseTestCase.test_attributes_without_netloccCs,|tjdd|tjdddS)Nz http://example.com?blahblah=/foo)rz example.comrrz blahblah=/foors http://example.com?blahblah=/foo)rs example.comrrs blahblah=/foorrrrCrCrD test_noslashs zUrlParseTestCase.test_noslashcCs||tjdd|tjdd|tjdd|tjdd|tjd d |tjd d dS) Nr1)rrr1rrrz//www.python.org:80)rwww.python.org:80rrrrhttp://www.python.org:80rrrrrrpath)rrrrrrs//www.python.org:80)rwww.python.org:80rrrrhttp://www.python.org:80rr rrrrrrrCrCrDtest_withoutschemes$z#UrlParseTestCase.test_withoutschemecCs|tjdd|tjdd|tjdd|tjdd|tjd d |tjd d |tjd d|tjdd|tjdd|tjdd|tjdd|tjdddS)Nzhttp:80)rr80rrrzhttps:80)rrr rrrzpath:80)r1rr rrrr)rrrrrrzhttps:)rrrrrrrrshttp:80)rr80rrrshttps:80)rrrrrrspath:80)rrrrrrshttp:)rrrrrrshttps:)rrrrrrr r rrrCrCrDtest_portseparators z#UrlParseTestCase.test_portseparatorcCs|ttjjddS)Nr)r TypeErrorr+r, urlencoderrCrCrD test_usingsysszUrlParseTestCase.test_usingsyscCs|tjdd|tjdd|tjdd|tjdd|tjd d |tjd d |tjd d|tjdddS)Nzs3://foo.com/stuff)Zs3foo.com/stuffrrrr) x-newschemerrrrrz*x-newscheme://foo.com/stuff?query#fragment)rrrrr3r4z!x-newscheme://foo.com/stuff?query)rrrrr3rss3://foo.com/stuff)ss3foo.com/stuffrrrsx-newscheme://foo.com/stuff) x-newschemerrrrrs*x-newscheme://foo.com/stuff?query#fragment)rrrrqueryrs!x-newscheme://foo.com/stuff?query)rrrrrrrrrCrCrDtest_anyschemes0zUrlParseTestCase.test_anyschemec CstjjtjjfD]}|j|d|dd}||jd|dd}||jd||ddjd||ddd jd||d dd jd||djd ||d jd ||d d jd Wdq1s0YqdS) N)functionzhttp://example.net/ftprshttp://example.net/sftprr1rrrr)r+r,r-r;rr.r/)r=funcrArCrCrDtest_default_scheme s  z$UrlParseTestCase.test_default_schemec Csd}|D] \}}}tjjtjjfD]}|dkr@|tjjur@d}|j||d||dd}||jd|t|| d||||ddjd||d d}||j|| t|| ||||dd j||||j|Wdq$1s0Yq$qdS) N) )z http:#fragr1r)z//example.net#fragr1r)zindex.html#fragr1r)z ;a=b#fragr2r)z ?a=b#fragr3r)z#fragr1r)z abc#@fragr1@frag)z //abc#@fragr1r)z//abc:80#@fragr1r)z//abc#@frag:80r1z@frag:80r2r1)r>rF)allow_fragmentsr#T) r+r,r-r;rr.r4Z assertTruegetattrendswithZ assertFalse)r=Ztestsr>attrZ expected_fragrrArCrCrDtest_parse_fragmentss*   z%UrlParseTestCase.test_parse_fragmentscCsL|tdtjddWdn1s00Y|tdtjddWdn1sj0Y|tdtjddWdn1s0Y|tdtjddWdn1s0Y|tdtjdWdn1s0Y|tdtjdWdn1sR0Y|tdtjdWdn1s0Y|tdtjd Wdn1s0Y|tdtjd d Wdn1s0Y|tdtjd d Wdn1s>0YdS) NzCannot mix strr}rrr)rr}rrrr)rrrrrr)rr}rrr)rrrrrrshttp://python.org) rrr+r,r-r;r5r<rrrCrCrDtest_mixed_types_rejected:s(,,,,,,,,.z*UrlParseTestCase.test_mixed_types_rejectedc Cs:t|j}|j}||j|d|}d|}||}||}d}d} ||||||||||||||||||||| ||||| |||||||||||||||||||||| ||||| |dS)N)r)rrlstrict)rK_fields_encoded_counterpartZassertIs_decoded_counterpartr.decodero) r=Zstr_typeZnum_argsZ bytes_typeZstr_argsZ bytes_argsZ str_resultZ bytes_resultencodingerrorsrCrCrD_check_result_typeRs.   z#UrlParseTestCase._check_result_typecCs.tjjtjjtjjg}|D]}||qdSr*)r+r, DefragResult SplitResult ParseResultr.)r=Z result_typesZ result_typerCrCrDtest_result_pairsks z"UrlParseTestCase.test_result_pairscCstjjddd}||ddgitjjddd}||ddgitjjddd}||dd gitjjd dd}||dd gitjjd dd d }||ddgidS)N key=Ł%E9latin-1r,keyŁé key=Ł%C3%A9utf-8rlŁ�� key=Ł%E9-Ł�-ignorer,r-Ł-)r+r,rYr.r=rArCrCrDtest_parse_qs_encodingus z'UrlParseTestCase.test_parse_qs_encodingcCstjjddd}||dgtjjddd}||dgtjjddd}||dgtjjd dd}||d gtjjd dd d }||d gdS)Nr3r4r5)r6r7r8r9rl)r6r:r;)r6r<r=r>)r6r?)r+r,rQr.r@rCrCrDtest_parse_qsl_encodings z(UrlParseTestCase.test_parse_qsl_encodingcCsf|t,tjjddgdddWdn1s<0YtjjddgddddS)Nrza=a )max_num_fields)rrr+r,rYjoinrrCrCrDtest_parse_qsl_max_num_fieldss :z.UrlParseTestCase.test_parse_qsl_max_num_fieldsc Csdifdifdddgifddgdgd fd dd d gifd ifdifdddgifddgdgdfddddgifg }|D]\}}|d|d|Ttjj|dd}|||d|tjj|d d}|||d|Wdqt1s0YqtdS)N;;;r!rr r#r rr a=1;a=2rr;;;r%rrr'rrra=1;a=2rr Original: , Expected:  separatorrH)rr+r,rYr.)r=Zparse_qs_semicolon_casesrRrSrA result_bytesrCrCrDtest_parse_qs_separators"   z(UrlParseTestCase.test_parse_qs_separatorc Csdgfdgfddgfdddgfdd d gfd gfd gfd dgfdddgfdddgfg }|D]\}}|d|d|Ttjj|dd}|||d|tjj|d d}|||d|WdqX1s0YqXdS)NrHrIr!r r#r r rJrrrKrLr%rr'rrrMrrrNrOrPrH)rr+r,rQr.)r=Zparse_qsl_semicolon_casesrRrSrArRrCrCrDtest_parse_qsl_separators"     z)UrlParseTestCase.test_parse_qsl_separatorcCsJtjddgddd}Gddd}tjd|id}||d dS) NrIrs)rr Tc@seZdZddZdS)z:UrlParseTestCase.test_urlencode_sequences..TrivialcSsdS)NZtrivialrCrrCrCrD__str__szBUrlParseTestCase.test_urlencode_sequences..Trivial.__str__N)__name__ __module__ __qualname__rWrCrCrCrDTrivialsr[rz a=trivial)r+r,rr.)r=rAr[rCrCrDtest_urlencode_sequencessz)UrlParseTestCase.test_urlencode_sequencescCsjtjddi}||dtjjdditjjd}||dtjjddidtjjd}||d dS) Nrz some valuez a=some+valuezsome value/another) quote_viaza=some%20value%2Fanotherr)safer]za=some%20value/another)r+r,rr.quoter@rCrCrDtest_urlencode_quote_vias    z)UrlParseTestCase.test_urlencode_quote_viacCsF|ttjjdtjd}||dtjd}||ddS)Nrsarchaeological arcanazarchaeological%20arcanarr)rrr+r,quote_from_bytesr.r@rCrCrDtest_quote_from_bytess    z&UrlParseTestCase.test_quote_from_bytescCs4tjd}||dtjd}||ddS)Nz abc%20defsabc defrr)r+r,unquote_to_bytesr.r@rCrCrDtest_unquote_to_bytess   z&UrlParseTestCase.test_unquote_to_bytescCs0|jttjjddd|jttjjddddS)Nsfoor9r5r')r-)rrr+r,r_rrCrCrDtest_quote_errorssz"UrlParseTestCase.test_quote_errorscCstjd}||jd||jdtjd}||jd||jdtjd}||jd||jdtjd}||jd||jddS)Nztel:+31-641044153telz +31-641044153ztel:+31641044153z +31641044153)r+r,r;r.r/r1r-)r=p1p2rCrCrDtest_issue14072s    z UrlParseTestCase.test_issue14072cCsd}tjd}|t||jWdn1s80Ytjd}|t||jWdn1sv0YdS)Nz3Port could not be cast to integer value as 'oracle'z%http://Server=sde; Service=sde:oracle)r+r,r-rrr:r;)r=messagergrhrCrCrD!test_port_casting_failure_messages $ z2UrlParseTestCase.test_port_casting_failure_messagecCstjd}||jd||jd||jdtjd}||jd||jd||jdtjd}||jd||jd ||jd tjd }||jd||jd ||jd dS)Nz"tel:123-4;phone-context=+1-650-516rfz123-4zphone-context=+1-650-516ztel:+1-201-555-0123z+1-201-555-0123rz"tel:7042;phone-context=example.comZ7042zphone-context=example.comz%tel:863-1234;phone-context=+1-914-555z863-1234zphone-context=+1-914-555)r+r,r-r.r/r1r2)r=rgrCrCrDtest_telurl_paramss     z#UrlParseTestCase.test_telurl_paramscCs$tjtjj}|dt|dS)NQuoter)r+r,rm _ALWAYS_SAFEassertInrepr)r=quoterrCrCrDtest_Quoter_reprsz!UrlParseTestCase.test_Quoter_reprcCsjg}hd}ttjD]>}|ds||vr.qttj|}t|dddkr||q|tjj|dS)N>splittag clear_cacheto_bytes splitquery splitport splittype splithost splitvalueunwrap splitattrrm splitnport splituser ResultBase splitpasswdrrYz urllib.parse)dirr+r, startswithr"appendZassertCountEqual__all__)r=rZ undocumentednameobjectrCrCrDtest_alls  zUrlParseTestCase.test_allc s2dddDfddtttdtjD}|d||d|tjd | t tjd Wdn1s0Yd D]}d D]}|D]}d || |}|j |d t |dF| t tj|Wdn1s0YWdq1s0YqqqdS)Nz/:#?@cSsh|]}dt|qS){:04X})formatordrMcrCrCrD /rz?UrlParseTestCase.test_urlsplit_normalization..cs.g|]&}tt|@r|vr|qSrC)set unicodedataZ decompositionr@rZ hex_charsZ illegal_charsrCrDrO0sz@UrlParseTestCase.test_urlsplit_normalization..u℀u#uhttp://プ:80uhttp://プ︓80)rrr)znetloc{}false.netloczn{}user@netlocz {}://{}/pathr)r>char)mapchrrsys maxunicoderor+r,r;rrrrr)r=Z denorm_charsr/r0rr>rCrrDtest_urlsplit_normalization*s"     * z,UrlParseTestCase.test_urlsplit_normalizationN)0rXrYrZrErUrZr|rrrrrrrrrrrrrrrrr rrrrr%r&r.r2rArBrGrSrTr\r`rbrdrerirkrlrrrrrCrCrCrDr)GsZ3  #&0-972 ]%)!     r)c@speZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) Utility_Testsz=Testcase to test the various utility functions in the urllib.cCs\tjj}||dd||dd||dd||dd||d d dS) Nztype:opaquestring)r opaquestringr)Nr :opaquestring)Nrztype:)rrztype:opaque:string)rz opaque:string)r+r, _splittyper.)r=rxrCrCrDtest_splittypeKs zUtility_Tests.test_splittypecCstjj}||dd||dd||dd||dd||d d ||d d ||d d||dd||dd||dddS)Nz%//www.example.org:80/foo/bar/baz.html)www.example.org:80/foo/bar/baz.htmlz//www.example.org:80)rrr)Nrz//127.0.0.1#@host.com) 127.0.0.1 /#@host.comz//127.0.0.1#@host.com:80)rz/#@host.com:80z//127.0.0.1:80#@host.com)z 127.0.0.1:80rz///file)rz/filez//example.net/file;) example.netz/file;z//example.net/file?)rz/file?z//example.net/file#)rz/file#)r+r, _splithostr.)r=ryrCrCrDtest_splithostSs>          zUtility_Tests.test_splithostcCs\tjj}||dd||dd||dd||dd||d d dS) Nr) User:Passwww.python.org:080z@www.python.org:080)rrr)Nrz User:Pass@)rrr)zUser@example.com:Passr)r+r, _splituserr.)r=r~rCrCrDtest_splituserps      zUtility_Tests.test_splitusercCstjj}||dd||dd||dd||dd||d d ||d d ||d d||dd||dd||dd||dd||dd||dddS)Nzuser:ab)userabzuser:a b)rza bzuser:a b)rza bzuser:a b)rza bzuser:a b)rza bzuser:a b)rza bzuser:a:b)rza:bzuser:a b)rr z user 2:ab)zuser 2rz user+1:a+b)zuser+1za+bzuser:)rrr)rNz:ab)rr)r+r, _splitpasswdr.)r=rrCrCrDtest_splitpasswd}szUtility_Tests.test_splitpasswdcCstjj}||dd||dd||dd||dd||dd ||d d ||d d ||dddS)N parrot:88)parrot88rrNparrot:r)rN parrot:cheese)rNz[::1]:88)[::1]rr)rNz:88)rr)r+r, _splitportr.)r=rwrCrCrDtest_splitportszUtility_Tests.test_splitportcCstjj}||dd||dd||ddd||dd||ddd||dd ||ddd ||d d ||d dd dS) Nr)rXr)r7)rrrr)rr)rrrr)r+r, _splitnportr.)r=r}rCrCrDtest_splitnportszUtility_Tests.test_splitnportcCsLtjj}||dd||dd||dd||dddS) Nhttp://python.org/fake?foo=bar)http://python.org/fakefoo=barzhttp://python.org/fake?foo=bar?)rrr)rNz?foo=bar)rr)r+r, _splitqueryr.)r=rvrCrCrDtest_splitquerys   zUtility_Tests.test_splitquerycCs\tjj}||dd||dd||dd||dd||d d dS) Nhttp://example.com?foo=bar#baz)http://example.com?foo=barbazzhttp://example.com?foo=bar#)rrz#baz)rrr)rNz"http://example.com?foo=bar#baz#boo)rZboo)r+r, _splittagr.)r=rsrCrCrD test_splittags    zUtility_Tests.test_splittagcCsftjj}||ddddgf||dddgf||ddddgf||ddgfdS)Nz/path;attr1=value1;attr2=value2z/pathz attr1=value1z attr2=value2z/path;rz;attr1=value1;attr2=value2)r+r, _splitattrr.)r=r|rCrCrDtest_splitattrs    zUtility_Tests.test_splitattrcCs\tjj}||dd||dd||dd||dd||d d dS) Nr)rbarzfoo=)rrz=bar)rrfoobar)rNz foo=bar=baz)rzbar=baz)r+r, _splitvaluer.)r=rzrCrCrDtest_splitvalues zUtility_Tests.test_splitvaluecCs.tjd}||d|ttjjddS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)r+r, _to_bytesr.r UnicodeErrorr@rCrCrD test_to_bytess    zUtility_Tests.test_to_bytescCs&dD]}tj|}||dqdS)N)zzzURL:scheme://host/pathscheme://host/pathr)r+r,r{r.)r=Z wrapped_urlr>rCrCrD test_unwraps zUtility_Tests.test_unwrapN)rXrYrZ__doc__rrrrrrrrrrrrrCrCrCrDrGs       rc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)DeprecationTestcCsL|t}tjdWdn1s,0Y|t|jddS)NrzUurllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() instead) assertWarnsDeprecationWarningr+r,rxr.strwarningr=cmrCrCrDtest_splittype_deprecations  * z*DeprecationTest.test_splittype_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzUurllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,ryr.rrrrCrCrDtest_splithost_deprecations  * z*DeprecationTest.test_splithost_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzUurllib.parse.splituser() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,r~r.rrrrCrCrDtest_splituser_deprecations  * z*DeprecationTest.test_splituser_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzWurllib.parse.splitpasswd() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,rr.rrrrCrCrDtest_splitpasswd_deprecations  * z,DeprecationTest.test_splitpasswd_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzUurllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,rwr.rrrrCrCrDtest_splitport_deprecations  * z*DeprecationTest.test_splitport_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzVurllib.parse.splitnport() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,r}r.rrrrCrCrDtest_splitnport_deprecations  * z+DeprecationTest.test_splitnport_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzVurllib.parse.splitquery() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,rvr.rrrrCrCrDtest_splitquery_deprecation s  * z+DeprecationTest.test_splitquery_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzTurllib.parse.splittag() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,rsr.rrrrCrCrDtest_splittag_deprecations  * z)DeprecationTest.test_splittag_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzUurllib.parse.splitattr() is deprecated as of 3.8, use urllib.parse.urlparse() instead)rrr+r,r|r.rrrrCrCrDtest_splitattr_deprecations  * z*DeprecationTest.test_splitattr_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)NrzWurllib.parse.splitvalue() is deprecated as of 3.8, use urllib.parse.parse_qsl() instead)rrr+r,rzr.rrrrCrCrDtest_splitvalue_deprecations  * z+DeprecationTest.test_splitvalue_deprecationcCsL|t}tjdWdn1s,0Y|t|jddS)Nrz/urllib.parse.to_bytes() is deprecated as of 3.8)rrr+r,rur.rrrrCrCrDtest_to_bytes_deprecation&s  * z)DeprecationTest.test_to_bytes_deprecationN)rXrYrZrrrrrrrrrrrrCrCrCrDrsr__main__)rrZunittest urllib.parser+rrrrrPrXZTestCaser)rrrXmainrCrCrCrDs                  O