ó
OyTLc           @   sŸ  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 m
 Z
 m Z d d l m Z d d l m	 Z d d l m Z d d l m Z yM d d l Z d d l Z e j d ƒ Z e j d	 e j d
 e j ƒ e Z Wn e k
 r&e Z d Z n Xd e f d „  ƒ  YZ  d e j! Z" d Z# d e j$ f d „  ƒ  YZ% d e j$ f d „  ƒ  YZ& d e j$ f d „  ƒ  YZ' d S(   s   Easy install Tests
iÿÿÿÿN(   t   StringIO(   t   easy_installt   get_script_argst   main(   t   PthDistributions(   R   (   t   Distributiont   test_easy_installt   levelt   streamt   FakeDistc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | d k r i  Si d d 6S(   Nt   console_scriptst   ept   name(    (   t   selft   group(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   get_entry_map   s    c         C   s   d S(   Nt   spec(    (   R   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   as_requirement   s    (   t   __name__t
   __module__R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyR	      s   	sü   #!%s
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('spec', 'console_scripts', 'name')()
    )
s0   from setuptools import setup

setup(name='foo')
t   TestEasyInstallTestc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s„   t  ƒ  } t | ƒ } t | _ t j ƒ  | _ z? | j ƒ  t j	 j
 | j d ƒ } |  j t j	 j | ƒ ƒ Wd  t j | j ƒ Xd  S(   Ns   site.py(   R   R   t   Falset   sitepy_installedt   tempfilet   mkdtempt   install_dirt   install_site_pyt   ost   patht   joint   assert_t   existst   shutilt   rmtree(   R   t   distt   cmdt   sitepy(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_install_site_py5   s    		
c         C   sO   t  ƒ  } t j } z t | ƒ j ƒ  \ } } Wd  | t _ X|  j | t ƒ d  S(   N(   R	   t   syst   platformR   t   nextt   assertEqualst   WANTED(   R   R"   t   old_platformR   t   script(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_get_script_argsA   s    		
c         C   sí   t  j ƒ  } t t j j | d ƒ d ƒ } | j d ƒ | j ƒ  t t j j | d ƒ d ƒ } | j t ƒ | j ƒ  d d l	 m
 } d „  } | j | _ | | _ t j ƒ  } z t j | ƒ t g  ƒ Wd  t j | ƒ t j | ƒ Xd  S(   Ns	   setup.cfgt   ws.   [easy_install]
find_links = http://example.coms   setup.pyiÿÿÿÿ(   R   c         S   s>   d } |  j  } d | k r7 d | d k s7 t | ‚ n  |  j S(   Ns!   Error: a local setup.cfg was usedR   t
   find_links(   t   command_optionst   AssertionErrort   _old_parse_command_line(   R   t   msgt   opts(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   _parse_command_lineZ   s
    	(   R   R   t   openR   R   R   t   writet   closet   SETUP_PYt   setuptools.distR   t   parse_command_lineR2   t   getcwdt   chdirR   R    R!   (   R   t   dirt	   setup_cfgt   setup_pyR   R5   t   old_wd(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_no_setup_cfgL   s"    

		c         C   s  t  ƒ  } t | ƒ } d „  | _ t | _ d d g | _ t j j t	 j
 ƒ  d ƒ | _ d g | _ | j ƒ  |  j | j j i  ƒ t | ƒ } d „  | _ d d g | _ t j j t	 j
 ƒ  d ƒ | _ d g | _ | j ƒ  | j j j ƒ  } | j ƒ  |  j | d d g ƒ d  S(   Nc           S   s   t  S(   N(   t   True(    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   <lambda>q   s    t   link1t   link2t   okc           S   s   t  S(   N(   RC   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyRD   {   s    (   R   R   t   check_pth_processingRC   t   no_find_linksR/   R   R   R   R   R   R   t   argst   ensure_finalizedR)   t   package_indext   scanned_urlst   keyst   sort(   R   R"   R#   RN   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_no_find_linksl   s$    		


(   R   R   R%   R-   RB   RP   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyR   3   s   			 t   TestPTHFileWriterc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sV   t  d t j ƒ  g ƒ } |  j | j ƒ | j t t j ƒ  ƒ ƒ |  j | j ƒ d S(   sb   a pth file manager should set dirty
        if a distribution is in site but also the cwd
        s   does-not_existN(   R   R   R<   R   t   dirtyt   addt   PRDistribution(   R   t   pth(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt!   test_add_from_cwd_site_sets_dirty†   s    c         C   sK   t  d d g ƒ } |  j | j ƒ | j t d ƒ ƒ |  j | j ƒ d  S(   Ns   does-not_exists%   /test/location/does-not-have-to-exist(   R   R   RR   RS   RT   (   R   RU   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_add_from_site_is_ignored   s    (   R   R   RV   RW   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyRQ   …   s   		t   TestUserInstallTestc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÜ   t  j ƒ  |  _ t j j |  j d ƒ } t | d ƒ } | j t ƒ | j	 ƒ  t j
 ƒ  |  _ t j |  j ƒ t j d k rØ t j |  _ t j |  _ t j |  _ t  j ƒ  t _ t j |  _ t  j ƒ  t _ t j t _ n  d  S(   Ns   setup.pyR.   s   2.6(   R   R   R>   R   R   R   R6   R7   R9   R8   R<   t   old_cwdR=   R&   t   versiont   easy_install_pkgt   HAS_USER_SITEt   old_has_sitet   __file__t   old_filet   sitet	   USER_BASEt   old_baset	   USER_SITEt   old_site(   R   t   setupt   f(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   setUp˜   s    
c         C   s†   t  j |  j ƒ t j |  j ƒ t j d k r‚ t j t j	 ƒ t j t j
 ƒ |  j t _	 |  j t _
 |  j t _ |  j t _ n  d  S(   Ns   2.6(   R   R=   RY   R    R!   R>   R&   RZ   R`   Ra   Rc   Rb   Rd   R]   R[   R\   R_   R^   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   tearDown©   s    c         C   sg   t  t _ t j d k  r d  St ƒ  } d | _ t | ƒ } d g | _ | j	 ƒ  |  j
 | j d ƒ d  S(   Ns   2.6s   setup.pyt   pys   user should be implied(   RC   R[   R\   R&   RZ   R   t   script_nameR   RJ   RK   t
   assertTruet   user(   R   R"   R#   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_user_install_implied´   s    			
c         C   s   t  s
 d  St j d ƒ d  S(   Ns   this should not break(   t
   _MULTIPROCt   _LOGt   info(   R   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_multiproc_atexitÀ   s    c         C   sg   t  t _ t j d k  r d  St ƒ  } d | _ t | ƒ } d g | _ | j	 ƒ  |  j
 | j d ƒ d  S(   Ns   2.6s   setup.pyRi   s   NOT user should be implied(   R   R[   R\   R&   RZ   R   Rj   R   RJ   t   initialize_optionst   assertFalseRl   (   R   R"   R#   (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt6   test_user_install_not_implied_without_usersite_enabledÅ   s    			
c   	      C   sj  t  j ƒ  } t  j ƒ  } t j j | d ƒ } t | d ƒ } y | j d ƒ Wn | j ƒ  n Xt j j	 | ƒ t j
 j d ƒ } d j t j ƒ t j
 d <zv t ƒ  } d | _ t | ƒ } | | _ d g | _ | j ƒ  | j j | g ƒ | j d ƒ } |  j | j | ƒ Wd  t j j | ƒ t j | ƒ t j | ƒ | d  k	 r[| t j
 d <n
 t j
 d =Xd  S(   Ns   foo-1.0.egg-infoR.   s
   Name: foo
t
   PYTHONPATHt   :s   setup.pyt   foo(   R   R   R   R   R   R6   R7   R8   R&   t   appendt   environt   getR   Rj   R   R   RJ   RK   t   local_indext   scanR)   t   locationt   removeR    R!   t   None(	   R   t   new_locationt   targett   egg_fileRf   t	   old_ppathR"   R#   t   res(    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   test_local_indexÑ   s6    			
(   R   R   Rg   Rh   Rm   Rq   Rt   R…   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyRX   –   s   					((   t   __doc__R&   R   R    R   t   unittestR`   R    t   setuptools.command.easy_installR   R   R   R   t   setuptools.commandR[   R:   R   t   pkg_resourcesRT   t   multiprocessingt   loggingt	   getLoggerRo   t   basicConfigt   INFOt   stderrRC   Rn   t   ImportErrorR   R   t   objectR	   t
   executableR*   R9   t   TestCaseR   RQ   RX   (    (    (    sF   /usr/lib/python2.7/dist-packages/setuptools/tests/test_easy_install.pyt   <module>   s0   0

R