ó
¨9Vc           @   sÒ   d  d l  m Z d  d l m Z d  d l Z d  d l 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  d l m Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   DistutilsOptionError(   t
   TestLoaderN(   t   resource_listdirt   resource_existst   normalize_patht   working_sett   _namespace_packagest   add_activation_listenert   requiret
   EntryPoint(   t   Command(   t   PY3(   t   unittest_maint   ScanningLoaderc           B   s   e  Z 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   testst   filet	   submodule(    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyR      s    (   R   t
   __module__R   (    (    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyR      s   t   testc           B   s_   e  Z d  Z d Z d d d g Z d „  Z d „  Z d „  Z d „  Z 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(   t   Nonet
   test_suitet   test_modulet   test_loadert   test_runner(   R   (    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   initialize_options9   s    			c         C   sü   |  j  d  k rC |  j d  k r0 |  j j  |  _  q[ |  j d |  _  n |  j r[ t d ƒ ‚ n  |  j  g |  _ |  j r‰ |  j j d 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(   Ns   .test_suites1   You may specify a module or a suite, but not bothi    s	   --verboseR'   s&   setuptools.command.test:ScanningLoaderR(   (   R%   R$   R&   t   distributionR    t	   test_argst   verboset   insertR'   t   getattrR(   (   R   (    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   finalize_options?   s     		c         C   sˆ  t  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 ƒ  } zX t	 j
 j d t | j ƒ ƒ t j ƒ  t d	 „  ƒ t d
 | j | j f ƒ | ƒ  Wd  | 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;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   <lambda>x   s    s   %s==%s(   R   R.   R*   t   Falset   reinitialize_commandt   run_commandt   get_finalized_commandR   t	   build_libt   syst   patht   modulest   copyR-   R4   R   t   __init__R   R   t   egg_namet   egg_versiont   cleart   update(   R   t   funct	   with_2to3t   bpy_cmdt
   build_patht   ei_cmdt   old_patht   old_modules(    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   with_project_on_sys_pathV   s4    


c         C   sª   |  j  j r% |  j  j |  j  j ƒ n  |  j  j rJ |  j  j |  j  j ƒ n  |  j r¦ d j |  j ƒ } |  j r‚ |  j d | ƒ q¦ |  j d | ƒ |  j	 |  j
 ƒ n  d  S(   Nt    s    skipping "unittest %s" (dry run)s   running "unittest %s"(   R*   t   install_requirest   fetch_build_eggst   tests_requireR%   t   joinR+   t   dry_runt   announceRN   t	   run_tests(   R   t   cmd(    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   run   s    			c      
   C   s  t  rÂ t |  j d t ƒ rÂ |  j d j d ƒ d } | t k rÂ g  } | t j k rf | j	 | ƒ n  | d 7} x0 t j D]% } | j
 | ƒ rz | j	 | ƒ qz qz Wt t t j j | ƒ ƒ qÂ n  t d  d  t j g |  j d |  j |  j ƒ d |  j |  j ƒ ƒd  S(   NR0   iÿÿÿÿR   i    t
   testLoadert
   testRunner(   R   R.   R*   R9   R+   t   splitR   R>   R@   R   t
   startswitht   listt   mapt   __delitem__R   R$   t   unittestt   __file__t   _resolve_as_epR'   R(   (   R   R   t   del_modulest   name(    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyRV      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;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyRb   ¦   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_optionsR)   R/   RN   RX   RV   t   staticmethodRb   (    (    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyR    -   s    				+		(   t   distutils.errorsR    R`   R   R>   t   pkg_resourcesR   R   R   R   R   R   R   R	   t
   setuptoolsR
   t   setuptools.compatR   t   setuptools.py31compatR   R   R    (    (    (    s;   /tmp/pip-build-5Z5nTX/setuptools/setuptools/command/test.pyt   <module>   s   :