ó
^†êWc           @   s  d  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 Z d d l Z d d l m	 Z	 d d l
 m Z d d l m Z d d l m Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   s   
Basic wheel tests.
iÿÿÿÿN(   t   resource_filename(   t	   egg2wheel(   t	   WheelFile(   t   ZipFile(   t   rmtrees   complex-dists   simple.dists   headers.distc          C   sl   t  j d d ƒ }  xS t D]K } xB d D]: } y  t t j j |  | | ƒ ƒ Wq& t k
 r_ q& Xq& Wq Wd S(   s$   Delete eggs/wheels created by tests.s
   wheel.testt    t   buildt   distN(   s   builds   dist(   t   pkg_resourcesR    t   test_distributionsR   t   ost   patht   joint   OSError(   t   baseR   t   subdir(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   teardown_module   s     c           C   s   t  ƒ  t ƒ  d  S(   N(   t   build_wheelt	   build_egg(    (    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   setup_module    s    c          B   s   x† e  D]~ }  e j j e j ƒ } e j d |  ƒ } e j | ƒ z3 d d g e _	 e
 e d ƒ j ƒ  d d ƒ d UWd e j | ƒ Xq Wd S(   s%   Build wheels from test distributions.s
   wheel.testR   t   bdist_wheels   setup.pyt   execN(   R	   R
   R   t   abspatht   curdirR   R    t   chdirt   syst   argvt   compilet   opent   read(   R   t   pwdt   distdir(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyR   $   s    $c          B   s   x† e  D]~ }  e j j e j ƒ } e j d |  ƒ } e j | ƒ z3 d d g e _	 e
 e d ƒ j ƒ  d d ƒ d UWd e j | ƒ Xq Wd S(   s#   Build eggs from test distributions.s
   wheel.testR   t	   bdist_eggs   setup.pyR   N(   R	   R
   R   R   R   R   R    R   R   R   R   R   R   (   R   R   R   (    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyR   0   s    $c           C   s   t  j j d j s t ‚ d S(   s$   Make sure pkg_resources can find us.t   wheelN(   R   t   working_sett   by_keyt   versiont   AssertionError(    (    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_findable<   s    c          C   sr   t  j d d ƒ }  t |  ƒ N } xD | D]< } | j ƒ  } | sF q( n  t j j | ƒ s( t | ƒ ‚ q( WWd QXd S(   s   Make sure egg_info_re matches.R!   s   eggnames.txtN(   R   R    R   t   stripR   t   egg_info_ret   matchR%   (   t   egg_names_patht	   egg_namest   line(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_egg_re@   s    c          C   s}   t  d ƒ }  t |  j ƒ d d g k s- t ‚ |  j d k sB t ‚ t  d ƒ } | j j ƒ  } | d d	 k sy t | ƒ ‚ d
 S(   s#   Test compatibilty tags are working.s(   package-1.0.0-cp32.cp33-noabi-noarch.whlt   cp32t   noabit   noarcht   cp33i   s'   package-1.0.0-1st-cp33-noabi-noarch.whlR   t   1stN(   R.   R/   s   noarch(   R1   R/   s   noarch(   R   t   listt   compatibility_tagsR%   t   arityt   parsed_filenamet	   groupdict(   t   wft   wf2t   wf2_info(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_compatibility_tagsJ   s    c          C   s‰   t  j d d ƒ }  xp t D]h } t j j |  | d ƒ } g  t j | ƒ D] } | j d ƒ rG | ^ qG } t j	 j
 | | d t ƒq Wd  S(   Ns
   wheel.testR   R   s   .eggt   verbose(   R   R    R	   R
   R   R   t   listdirt   endswithR!   t   toolt   convertt   False(   R   R   R   t   et   eggs(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_convert_eggU   s
    1c          C   s|   xu t  D]m }  t j d t j j |  d ƒ ƒ } xC d „  t j | ƒ Dƒ D]( } t j j	 t j j | | ƒ | ƒ qH Wq Wd S(   sj   
    Make sure 'wheel unpack' works.
    This also verifies the integrity of our testing wheel files.
    s
   wheel.testR   c         s   s$   |  ] } | j  d  ƒ r | Vq d S(   s   .whlN(   R>   (   t   .0t   w(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pys	   <genexpr>d   s    N(
   R	   R   R    R
   R   R   R=   R!   R?   t   unpack(   R   R   t	   wheelfile(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_unpack\   s
    	 c          C   s©   d }  t  j d |  ƒ } xŠ t j | ƒ D]y \ } } } xg | D]_ } | j d ƒ r> t t j j | | ƒ ƒ } x, | j ƒ  D] } d | j	 k s{ t
 ‚ q{ Wq> q> Wq( Wd S(   s0   Make sure entry point scripts are not generated.s   complex-dists
   wheel.tests   .whls   .data/scripts/N(   R   R    R
   t   walkR>   R   R   R   t   infolistt   filenameR%   (   R   t   basedirt   dirnamet   subdirst	   filenamesRL   t   whlt   entry(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_no_scriptsg   s    c          C   s7  d d l  }  d „  } | t d d ƒ ƒ } d } xè d D]à } t j d | ƒ } xÅ t j | ƒ D]´ \ } } } x¢ | D]š }	 |	 j d	 ƒ ru t t j j | |	 ƒ ƒ }
 xg |
 j	 ƒ  D]V } | j
 j d
 ƒ r² t j |
 j | ƒ j d ƒ ƒ } |  j | | ƒ | d 7} q² q² Wqu qu Wq_ Wq7 W| d k s3t d ƒ ‚ d S(   s>   Make sure pydist.json exists and validates against our schema.iÿÿÿÿNc         S   s8   t  |  d ƒ # } t j | j ƒ  j d ƒ ƒ SWd  QXd  S(   Nt   rbs   utf-8(   R   t   jsont   loadsR   t   decode(   RL   t	   json_file(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt	   open_jsonx   s    s
   wheel.tests   pydist-schema.jsoni    s   simple.dists   complex-dists   .whls   /metadata.jsons   utf-8i   s   No metadata.json found(   s   simple.dists   complex-dist(   t
   jsonschemaR    R   R
   RJ   R>   R   R   R   RK   RL   RU   RV   R   RW   t   validateR%   (   RZ   RY   t   pymeta_schemat   validR   RM   RN   RO   RP   RL   RQ   RR   t   pymeta(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_pydistr   s"    		! c          C   sq   xj t  d ƒ D]\ }  d |  } t j j | ƒ } | j d ƒ sE t ‚ t j j | ƒ } | | k s t ‚ q Wd S(   s   Test functions in util.py.i
   t   *t   =N(   t   rangeR!   t   utilt   urlsafe_b64encodeR>   R%   t   urlsafe_b64decode(   t   it   beforet   encodedt   after(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt	   test_utilŒ   s    
c    
         sê   d „  }  d d d d d d g } g  | D] } t  d
 | ƒ ^ q( } d d g } d d d d g } d d d d g } xo | | | f D]^ ‰  ‡  f d †  } x | D] } | | _ q  Wt | ƒ }	 t |	 j ƒ d ˆ  d k s„ t ‚ q„ Wd S(   s!   Test the wheel ranking algorithm.c         S   s,   |  d j  j ƒ  } | d | d | d f S(   Niÿÿÿÿt   pyvert   abit   plat(   R6   R7   (   t   rest   info(    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   get_tags˜   s    t   py27R/   R0   t   py26t   cp27t
   linux_i686t   cp26t   linux_x86_64s   testpkg-1.0-%s-%s-%s.whlc              s
   t  ˆ  ƒ S(   N(   R3   (    (   t   supp(    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   <lambda>«   s    i    N(   Rq   s   noabis   noarch(   Rr   s   noabis   noarch(   Rs   s   noabis
   linux_i686(   Ru   s   noabis
   linux_i686(   Rs   s   noabis   linux_x86_64(   Ru   s   noabis   linux_x86_64(   Rs   s   noabis
   linux_i686(   Rq   s   noabis   noarch(   Rs   s   noabis
   linux_i686(   Rq   s   noabis   noarch(   Ru   s   noabis
   linux_i686(   Rr   s   noabis   noarch(   Ru   s   noabis
   linux_i686(   Rr   s   noabis   noarch(   Rs   s   noabis
   linux_i686(   Rq   s   noabis   noarch(   R   t   contextt   maxR3   t   tagsR%   (
   Rp   t	   cand_tagst   tt   cand_wheelst	   supportedt
   supported2t
   supported3Ry   R!   t   best(    (   Rw   sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   test_pick_best–   s&    		 (   s   complex-dists   simple.dists   headers.dist(   t   __doc__R
   R   RU   R   R    t
   wheel.utilR!   t
   wheel.toolR   t   wheel.installR   t   zipfileR   t   shutilR   R	   R   R   R   R   R&   R-   R;   RD   RI   RS   R_   Rj   Rƒ   (    (    (    sh   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_basic.pyt   <module>   s2   	
					
						
