ó «©\Tc@sªdZddlZddlZddlZddlmZmZmZmZddl Z ddl Z ddl mZdejfd„ƒYZdejfd„ƒYZdS( sPackage Index Tests iÿÿÿÿN(turllib2thttplibt HTTPErrortunicode(t IndexServertTestPackageIndexcBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cCstjjƒ}d}y|j|ƒ}Wn:tk rdtjƒd}|j|t|ƒkƒnX|jt |t ƒƒdS(Ns.http://127.0.0.1:0/nonesuch/test_package_indexi( t setuptoolst package_indext PackageIndextopen_urlt Exceptiontsystexc_infot assertTruetstrt isinstanceR(tselftindexturltv((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_bad_port s cCs…tjjddƒ}d}y|j|ƒ}Wn:tk rjtjƒd}|j|t|ƒkƒnX|jt |t ƒƒdS(Nthostsswww.example.comsMurl:%20https://svn.plone.org/svn/collective/inquant.contentmirror.plone/trunki(swww.example.com( RRRR R R R R RRR(RRRR((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_typos   cCstjjddƒ}d„}||_d}y|j|ƒ}Wn:tk r|tjƒd}|jdt |ƒkƒn Xt dƒ‚dS( NRswww.example.comcWstjdƒ‚dS(Ntline(Rt BadStatusLine(targs((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyt_urlopen.sshttp://example.comiRsShould have raise here!(swww.example.com( RRRtopenerR R R R R RtAssertionError(RRRRR((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_bad_status_line)s     cCstjjdd ƒ}d}y|j|ƒWn^tjjk rŒtjƒd}t |ƒ}d|ksˆd|ksˆd|ksˆt ‚dSXt d ƒ‚dS( sO A bad URL with a double scheme should raise a DistutilsError. Rswww.example.coms2http://http://svn.pythonpaste.org/Paste/wphp/trunkisnonnumeric portsgetaddrinfo failedsName or service not knownNs Did not raise(swww.example.com( RRRR t distutilsterrorstDistutilsErrorR R RRt RuntimeError(RRRterrortmsg((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_double_scheme;s   *cCs^tjjdd ƒ}tjddkrZtjddkrZd}d}|j||ƒndS( NRswww.example.comiiiishttp://example.coms>(swww.example.com(RRRR t version_infot process_index(RRRtpage((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_screwy_hrefNs   &cCs8tjjddƒ}d}|j|j|tƒƒdS(NRswww.example.comsfile:///tmp/test_package_index(swww.example.com(RRRR turl_oktTrue(RRR((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyt test_url_ok[s  cCsÆtjjdƒrdStƒ}|jƒ|jƒd}tjj|ƒ}t j j dƒ}|j |ƒ|j ƒ|jd|kƒ|jt|dƒdkƒ|jd|ddjkƒdS(sq Download links from the pypi simple index should be used before external download links. https://bitbucket.org/tarek/distribute/issue/163 Usecase : - someone uploads a package on pypi, a md5 is generated - someone manually copies this link (with the md5 in the url) onto an external page accessible from the package page. - someone reuploads the package (with a different md5) - while easy_installing, an MD5 error occurs because the external link is used -> Setuptools should use the link from pypi, not the external one. tjavaNstest_links_priority/simple/tfoobarit correct_md5i(R tplatformt startswithRtstarttbase_urlRRRt pkg_resourcest Requirementtparset find_packageststopR tlentlocation(Rtservert index_urltpit requirement((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_links_prioritybs    cCst|jtjjdƒd ƒ|jtjjdƒd ƒ|jtjjdƒd ƒ|jtjjd ƒd ƒdS(Nsreportlab-2.5.win32-py2.4.exes reportlab-2.5s2.4twin32sreportlab-2.5.win32.exes!reportlab-2.5.win-amd64-py2.7.exes2.7s win-amd64sreportlab-2.5.win-amd64.exe(s reportlab-2.5s2.4swin32(s reportlab-2.5Nswin32(s reportlab-2.5s2.7s win-amd64(s reportlab-2.5Ns win-amd64(t assertEqualRRtparse_bdist_wininsttNone(R((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_parse_bdist_wininst‡s   cCsEtjjj}|dƒ\}}|j|dƒ|j|dƒdS(sA Test the basic usage of _vcs_split_rev_from_url shttps://example.com/bar@2995shttps://example.com/bart2995N(RRRt_vcs_split_rev_from_urlR@(RtvsrfuRtrev((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest__vcs_split_rev_from_url‘s( t__name__t __module__RRRR$R(R+R>RCRH(((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyR s     % tTestContentCheckerscBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs[tjjjdƒ}|jdjdƒƒ|j|jjƒdƒ|j |j ƒƒdS(Ns3http://foo/bar#md5=f12895fdffbd45007040d2e44df98478s$You should probably not be using MD5tasciit f12895fdffbd45007040d2e44df98478( RRt HashCheckertfrom_urltfeedtencodeR@thasht hexdigestR tis_valid(Rtchecker((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_md5œs   cCsBtjjjdƒ}|jdjdƒƒ|j|jƒƒdS(s<Content checks should succeed silently if no hash is presents1http://foo/bar#something%20completely%20differenttanythingRLN(RRRNRORPRQR RT(RRU((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_other_fragment¤s  cCsBtjjjdƒ}|jdjdƒƒ|j|jƒƒdS(s0Content checks should succeed if a hash is emptyshttp://foo/bar#md5=RWRLN(RRRNRORPRQR RT(RRU((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_blank_md5«s  cCs,tjjjdƒ}|j|jdƒdS(Ns3http://foo/bar#md5=f12895fdffbd45007040d2e44df98478tmd5(RRRNROR@t hash_name(RRU((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_get_hash_name_md5²s  cCs>tjjjdƒ}|jd„dƒ}|j|dƒdS(Ns3http://foo/bar#md5=f12895fdffbd45007040d2e44df98478cSs|S(N((tx((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pytºssMy message about %ssMy message about md5(RRRNROtreportR@(RRUtrep((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyt test_report·s  (RIRJRVRXRYR\Ra(((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyRKšs     (t__doc__R tunittestR3tsetuptools.compatRRRRtdistutils.errorsRtsetuptools.package_indexRtsetuptools.tests.serverRtTestCaseRRK(((sO/opt/freeware/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyts   "