ó
1,^c           @   sM  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 m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l m Z d	 d
 l m Z e Z  d e f d „  ƒ  YZ! d d d „  ƒ  YZ" d e f d „  ƒ  YZ# d S(   iÿÿÿÿN(   t   DistutilsErrort   DistutilsOptionError(   t   log(   t
   TestLoader(   t   six(   t   mapt   filter(	   t   resource_listdirt   resource_existst   normalize_patht   working_sett   _namespace_packagest   evaluate_markert   add_activation_listenert   requiret
   EntryPoint(   t   Commandi   (   t   _unique_everseent   ScanningLoaderc           B   s   e  Z d  „  Z d d „ Z RS(   c         C   s   t  j |  ƒ t ƒ  |  _ d  S(   N(   R   t   __init__t   sett   _visited(   t   self(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR      s    c         C   s7  | |  j  k r d S|  j  j | ƒ g  } | j t j |  | ƒ ƒ t | d ƒ rg | j | j ƒ  ƒ n  t | d ƒ rx“ t | j	 d ƒ D]| } | j
 d ƒ rÂ | d k rÂ | j	 d | d  } n- t | j	 | d ƒ r‰ | j	 d | } n q‰ | j |  j | ƒ ƒ q‰ Wn  t | ƒ d	 k r+|  j | ƒ S| d
 Sd S(   s  Return a suite of all tests cases contained in the given module

        If the module is a package, load tests from all the modules in it.
        If the module has an ``additional_tests`` function, call it and add
        the return value to the tests.
        t   additional_testst   __path__t    s   .pys   __init__.pyt   .iýÿÿÿs   /__init__.pyi   i    N(   R   t   Nonet   addt   appendR   t   loadTestsFromModulet   hasattrR   R   t   __name__t   endswithR   t   loadTestsFromNamet   lent
   suiteClass(   R   t   modulet   patternt   testst   filet	   submodule(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR      s$    N(   R    t
   __module__R   R   R   (    (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR      s   	t   NonDataPropertyc           B   s   e  Z d  „  Z d d „ Z RS(   c         C   s   | |  _  d  S(   N(   t   fget(   R   R,   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR   A   s    c         C   s   | d  k r |  S|  j | ƒ S(   N(   R   R,   (   R   t   objt   objtype(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   __get__D   s    N(   R    R*   R   R   R/   (    (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR+   @   s   	t   testc           B   sÂ   e  Z d  Z d Z d d d g Z d „  Z d „  Z e d „  ƒ Z d „  Z	 d „  Z
 e j g  d „ ƒ Z e e j d „  ƒ ƒ Z e d „  ƒ Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   s.   Command to run unit tests after in-place builds0   run unit tests after in-place build (deprecated)s   test-module=t   ms$   Run 'test_suite' in specified modules   test-suite=t   ss9   Run single test, case or suite (e.g. 'module.test_suite')s   test-runner=t   rs   Test runner to usec         C   s(   d  |  _ d  |  _ d  |  _ d  |  _ d  S(   N(   R   t
   test_suitet   test_modulet   test_loadert   test_runner(   R   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   initialize_optionsV   s    			c         C   sÝ   |  j  r' |  j r' d } t | ƒ ‚ n  |  j  d  k rj |  j d  k rW |  j j  |  _  qj |  j d |  _  n  |  j d  k r” t |  j d d  ƒ |  _ n  |  j d  k r¯ d |  _ n  |  j d  k rÙ t |  j d d  ƒ |  _ n  d  S(   Ns1   You may specify a module or a suite, but not boths   .test_suiteR6   s&   setuptools.command.test:ScanningLoaderR7   (   R4   R5   R   R   t   distributionR6   t   getattrR7   (   R   t   msg(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   finalize_options\   s    c         C   s   t  |  j ƒ  ƒ S(   N(   t   listt
   _test_args(   R   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt	   test_argso   s    c         c   sJ   |  j  r! t j d k r! d Vn  |  j r2 d Vn  |  j  rF |  j  Vn  d  S(   Ni   i   t   discovers	   --verbose(   i   i   (   R4   t   syst   version_infot   verbose(   R   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR>   s   s    		c         C   s   |  j  ƒ   | ƒ  Wd QXd S(   sI   
        Backward compatibility for project_on_sys_path context.
        N(   t   project_on_sys_path(   R   t   func(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   with_project_on_sys_path{   s    c   	      c   s¨  t  j o t |  j d t ƒ } | r¥ |  j d d d ƒ|  j d ƒ |  j d ƒ } t | j	 ƒ } |  j d d | ƒ|  j d ƒ |  j d d d ƒ|  j d ƒ n- |  j d ƒ |  j d d d ƒ|  j d ƒ |  j d ƒ } t
 j } t
 j j ƒ  } zu t | j ƒ } t
 j j d | ƒ t j ƒ  t d	 „  ƒ t d
 | j | j f ƒ |  j | g ƒ 
 d  VWd  QXWd  | t
 j (t
 j j ƒ  t
 j j | ƒ t j ƒ  Xd  S(   Nt   use_2to3t   build_pyt   inplacei    t   egg_infot   egg_baset	   build_exti   c         S   s
   |  j  ƒ  S(   N(   t   activate(   t   dist(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   <lambda>¦   s    s   %s==%s(   R   t   PY3R:   R9   t   Falset   reinitialize_commandt   run_commandt   get_finalized_commandR	   t	   build_libRA   t   patht   modulest   copyRK   t   insertR
   R   R   R   t   egg_namet   egg_versiont   paths_on_pythonpatht   cleart   update(	   R   t   include_distst	   with_2to3t   bpy_cmdt
   build_patht   ei_cmdt   old_patht   old_modulest   project_path(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyRD   ‚   s8    


c         c   sÈ   t  ƒ  } t j j d | ƒ } t j j d d ƒ } z^ t j j t |  ƒ ƒ } t d | | g ƒ } t j j | ƒ } | r‹ | t j d <n  d VWd | | k r¶ t j j	 d d ƒ n | t j d <Xd S(   së   
        Add the indicated paths to the head of the PYTHONPATH environment
        variable so that subprocesses will also see the packages at
        these paths.

        Do this in a context that restores the value on exit.
        t
   PYTHONPATHR   N(
   t   objectt   ost   environt   gett   pathsept   joinR   R   R   t   pop(   t   pathst   nothingt   orig_pythonpatht   current_pythonpatht   prefixt   to_joint   new_path(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR\   °   s    
		c         C   s_   |  j  |  j ƒ } |  j  |  j p$ g  ƒ } |  j  d „  |  j j ƒ  Dƒ ƒ } t j | | | ƒ S(   s†   
        Install the requirements indicated by self.distribution and
        return an iterable of the dists that were built.
        c         s   s:   |  ]0 \ } } | j  d  ƒ r t | d ƒ r | Vq d S(   t   :i   N(   t
   startswithR   (   t   .0t   kt   v(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pys	   <genexpr>Ó   s    	(   t   fetch_build_eggst   install_requirest   tests_requiret   extras_requiret   itemst	   itertoolst   chain(   RN   t   ir_dt   tr_dt   er_d(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   install_distsÊ   s
    c      	   C   sµ   |  j  d t j ƒ |  j |  j ƒ } d j |  j ƒ } |  j rU |  j  d | ƒ d  S|  j  d | ƒ t t	 j
 d ƒ | ƒ } |  j | ƒ " |  j ƒ   |  j ƒ  Wd  QXWd  QXd  S(   Ns»   WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.t    s   skipping "%s" (dry run)s   running "%s"t   location(   t   announceR   t   WARNR…   R9   Rm   t   _argvt   dry_runR   t   operatort
   attrgetterR\   RD   t	   run_tests(   R   t   installed_distst   cmdRo   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   runØ   s    
	c      
   C   sE  t  j rÁ t |  j d t ƒ rÁ |  j j d ƒ d } | t k rÁ g  } | t j	 k re | j
 | ƒ n  | d 7} x0 t j	 D]% } | j | ƒ ry | j
 | ƒ qy qy Wt t t j	 j | ƒ ƒ qÁ n  t j d  d  |  j d |  j |  j ƒ d |  j |  j ƒ d t ƒ} | j j ƒ  sAd | j } |  j | t j ƒ t | ƒ ‚ n  d  S(   NRG   R   i    t
   testLoadert
   testRunnert   exits   Test failed: %s(   R   RP   R:   R9   RQ   R4   t   splitR   RA   RW   R   Rw   R=   R   t   __delitem__t   unittestt   mainR   RŠ   t   _resolve_as_epR6   R7   t   resultt   wasSuccessfulRˆ   R   t   ERRORR    (   R   R%   t   del_modulest   nameR0   R;   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyRŽ   ï   s(    
	c         C   s   d g |  j  S(   NR—   (   R?   (   R   (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyRŠ   
  s    c         C   s0   |  d k r d St j d |  ƒ } | j ƒ  ƒ  S(   su   
        Load the indicated attribute value, called, as a as if it were
        specified as an entry point.
        Ns   x=(   R   R   t   parset   resolve(   t   valt   parsed(    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR™     s    (   s   test-module=R1   s$   Run 'test_suite' in specified module(   s   test-suite=R2   s9   Run single test, case or suite (e.g. 'module.test_suite')(   s   test-runner=R3   s   Test runner to use(   R    R*   t   __doc__t   descriptiont   user_optionsR8   R<   R+   R?   R>   RF   t
   contextlibt   contextmanagerRD   t   staticmethodR\   R…   R‘   RŽ   t   propertyRŠ   R™   (    (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyR0   J   s(    					-		(    ($   Ri   RŒ   RA   R¦   R€   R—   t   distutils.errorsR    R   t	   distutilsR   R   t   setuptools.externR   t   setuptools.extern.six.movesR   R   t   pkg_resourcesR   R   R	   R
   R   R   R   R   R   t
   setuptoolsR   RH   R   t   typet   __metaclass__R   R+   R0   (    (    (    s6   lib/python2.7/site-packages/setuptools/command/test.pyt   <module>   s"   @)
