ó
%}Xc           @   s8  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 d  d l m Z d  d	 l m Z d
 e f d „  ƒ  YZ d e f 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   add_activation_listenert   requiret
   EntryPoint(   t   Command(   t   unittest_maint   ScanningLoaderc           B   s   e  Z d d  „ Z RS(   c         C   s  g  } | j  t j |  | ƒ ƒ t | d ƒ rD | j  | j ƒ  ƒ n  t | d ƒ ré x“ t | j d ƒ D]| } | j d ƒ rŸ | d k rŸ | j d | d  } n- t | j | d ƒ rf | j d | } n qf | j  |  j	 | ƒ ƒ qf 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(   t   appendR   t   loadTestsFromModulet   hasattrR   R   t   __name__t   endswithR   t   loadTestsFromNamet   lent
   suiteClass(   t   selft   modulet   patternt   testst   filet	   submodule(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR      s    N(   R   t
   __module__t   NoneR   (    (    (    s;   /usr/lib/python2.7/dist-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'   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   __init__5   s    c         C   s   | d  k r |  S|  j | ƒ S(   N(   R%   R'   (   R   t   objt   objtype(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   __get__8   s    N(   R   R$   R(   R%   R+   (    (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR&   4   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 builds#   run unit tests after in-place builds   test-module=t   ms$   Run 'test_suite' in specified modules   test-suite=t   ss1   Test suite to run (e.g. 'some_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   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   initialize_optionsJ   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_suiteR2   s&   setuptools.command.test:ScanningLoaderR3   (   R0   R1   R   R%   t   distributionR2   t   getattrR3   (   R   t   msg(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   finalize_optionsP   s    c         C   s   t  |  j ƒ  ƒ S(   N(   t   listt
   _test_args(   R   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt	   test_argsc   s    c         c   s)   |  j  r d Vn  |  j r% |  j Vn  d  S(   Ns	   --verbose(   t   verboseR0   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR:   g   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(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   with_project_on_sys_pathm   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(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   <lambda>˜   s    s   %s==%s(   R   t   PY3R6   R5   t   Falset   reinitialize_commandt   run_commandt   get_finalized_commandR	   t	   build_libt   syst   patht   modulest   copyRD   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(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR=   t   s8    


c         c   sÂ   t  ƒ  } t j j d | ƒ } t j j d d ƒ } zX t j j |  ƒ } 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%   t   pop(   t   pathst   nothingt   orig_pythonpatht   current_pythonpatht   prefixt   to_joint   new_path(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyRV   ¢   s    
		c         C   s@   |  j  |  j p g  ƒ } |  j  |  j p* g  ƒ } t j | | ƒ S(   s†   
        Install the requirements indicated by self.distribution and
        return an iterable of the dists that were built.
        (   t   fetch_build_eggst   install_requirest   tests_requiret	   itertoolst   chain(   RG   t   ir_dt   tr_d(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   install_dists¼   s    c      	   C   s¢   |  j  |  j ƒ } d j |  j ƒ } |  j rB |  j d | ƒ d  S|  j d | ƒ t t j d ƒ | ƒ } |  j	 | ƒ " |  j
 ƒ   |  j ƒ  Wd  QXWd  QXd  S(   Nt    s   skipping "%s" (dry run)s   running "%s"t   location(   Rw   R5   Rg   t   _argvt   dry_runt   announceR   t   operatort
   attrgetterRV   R=   t	   run_tests(   R   t   installed_distst   cmdRi   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   runÆ   s    	c      	   C   sa  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
 k  rÖ i  n
 i t d 6} t d  d  |  j d |  j |  j ƒ d |  j |  j ƒ | } | j j ƒ  s]d	 | j } |  j | t j ƒ t | ƒ ‚ n  d  S(   NR@   R   i    i   i   t   exitt
   testLoadert
   testRunners   Test failed: %s(   i   i   (   R   RI   R6   R5   RJ   R0   t   splitR   RO   RQ   R   t
   startswithR9   R   t   __delitem__t   version_infoR   R%   Rz   t   _resolve_as_epR2   R3   t   resultt   wasSuccessfulR|   R   t   ERRORR    (   R   R   t   del_modulest   namet
   exit_kwargR,   R7   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR   Õ   s*    
"	c         C   s   d g |  j  S(   Nt   unittest(   R;   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyRz   ñ   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(    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyRŠ   õ   s    (   s   test-module=R-   s$   Run 'test_suite' in specified module(   s   test-suite=R.   s1   Test suite to run (e.g. 'some_module.test_suite')(   s   test-runner=R/   s   Test runner to use(   R   R$   t   __doc__t   descriptiont   user_optionsR4   R8   R&   R;   R:   R?   t
   contextlibt   contextmanagerR=   t   staticmethodRV   Rw   R‚   R   t   propertyRz   RŠ   (    (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyR,   >   s(    					-
		("   Rc   R}   RO   R™   Rs   t   distutils.errorsR    R   t	   distutilsR   R‘   R   t   setuptools.externR   t   setuptools.extern.six.movesR   R   t   pkg_resourcesR   R   R	   R
   R   R   R   R   t
   setuptoolsR   t   setuptools.py31compatR   R   Rb   R&   R,   (    (    (    s;   /usr/lib/python2.7/dist-packages/setuptools/command/test.pyt   <module>   s   : 
