ó k޹Sc@s¼dZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl Z ddl ZddlmZdejfd„ƒYZdejfd„ƒYZdS( sPackage Index Tests iÿÿÿÿN(turllib2thttplibt HTTPErrortunicodet pathname2url(t IndexServertTestPackageIndexcBsbeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„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((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_bad_ports 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( RRR R R R R RRRR(RRRR((sL/usr/local/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((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyt_urlopen/sshttp://example.comiRsShould have raise here!(swww.example.com( RRR topenerR R R R RRtAssertionError(RRRRR((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_bad_status_line*s     cCsstjjddƒ}d}y|j|ƒWn4tjjk rbtjƒd}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/trunkiNs Did not raise(swww.example.com( RRR R t distutilsterrorstDistutilsErrorR R Rt RuntimeError(RRRterrortmsg((sL/usr/local/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(RRR R t version_infot process_index(RRRtpage((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_bad_url_screwy_hrefOs   &cCs8tjjddƒ}d}|j|j|tƒƒdS(NRswww.example.comsfile:///tmp/test_package_index(swww.example.com(RRR Rturl_oktTrue(RRR((sL/usr/local/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_urlRRR t pkg_resourcest Requirementtparset find_packageststopRtlentlocation(Rtservert index_urltpit requirement((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_links_prioritycs    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((sL/usr/local/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(RRR t_vcs_split_rev_from_urlRA(RtvsrfuRtrev((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest__vcs_split_rev_from_url’scCsktddƒ}|jdƒ|jƒz0dttjƒƒd}tjj|ƒ}Wdtj dƒXdS(sR local_open should be able to read an index from the file system. s index.htmltws
content
sfile:t/N( topentwritetcloseRtostgetcwdRRt local_opentremove(RtfRtres((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_local_index›s  ( t__name__t __module__RRRR%R)R,R?RDRIRU(((sL/usr/local/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_urltfeedtencodeRAthasht hexdigestRtis_valid(Rtchecker((sL/usr/local/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%20differenttanythingRYN(RRR[R\R]R^RRa(RRb((sL/usr/local/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=RdRYN(RRR[R\R]R^RRa(RRb((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyttest_blank_md5»s  cCs,tjjjdƒ}|j|jdƒdS(Ns3http://foo/bar#md5=f12895fdffbd45007040d2e44df98478tmd5(RRR[R\RAt hash_name(RRb((sL/usr/local/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((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pytÊssMy message about %ssMy message about md5(RRR[R\treportRA(RRbtrep((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyt test_reportÇs  (RVRWRcReRfRiRn(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyRXªs     (t__doc__R ROtunittestR4tsetuptools.compatRRRRRtdistutils.errorsRtsetuptools.package_indexRtsetuptools.tests.serverRtTestCaseRRX(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_packageindex.pyts    (  ž