ó
;^c           @   s  d  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	 m
 Z
 m Z m Z e j e ƒ Z d d d g Z e j j Z e j j Z e j j Z e j j Z e j j Z e j j Z d e f d „  ƒ  YZ e Z  d e f d	 „  ƒ  YZ! d S(
   s»   
Test Selection
--------------

Test selection is handled by a Selector. The test loader calls the
appropriate selector method for each object it encounters that it
thinks may be a test.
iÿÿÿÿN(   t   Config(   t   split_test_namet   srct   getfilenamet
   getpackaget	   ispackaget   is_executablet   Selectort   defaultSelectort   TestAddressc           B   s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s¥   Core test selector. Examines test candidates and determines whether,
    given the specified configuration, the test candidate should be selected
    as a test.
    c         C   s)   | d  k r t ƒ  } n  |  j | ƒ d  S(   N(   t   NoneR    t	   configure(   t   selft   config(    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   __init__"   s    c         C   sI   | |  _  | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ d  S(   N(   R   t   excludet   ignoreFilest   includet   pluginst	   testMatcht   match(   R   R   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR   '   s    	c         C   s€   |  j  j | ƒ sI |  j o t d g  |  j D] } | j | ƒ ^ q+ ƒ o |  j p t d g  |  j D] } | j | ƒ ^ qc ƒ S(   s¢   Does the name match my requirements?

        To match, a name must match config.testMatch OR config.include
        and it must not match config.exclude
        N(   R   t   searchR   t   filterR
   R   (   R   t   namet   inct   exc(    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   matches/   s    	(
c         C   s¯   t  | d d ƒ } | d k	 r' | } n7 | j j d ƒ o[ t | t j ƒ p[ |  j | j ƒ } |  j j	 | ƒ } | d k	 r˜ t
 j d | | ƒ | } n  t
 j d | | ƒ | S(   s¹   Is the class a wanted test class?

        A class must be a unittest.TestCase subclass, or match test name
        requirements. Classes that start with _ are always excluded.
        t   __test__t   _s$   Plugin setting selection of %s to %ss   wantClass %s? %sN(   t   getattrR
   t   __name__t
   startswitht
   issubclasst   unittestt   TestCaseR   R   t	   wantClasst   logt   debug(   R   t   clst   declaredt   wantedt
   plug_wants(    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR#   >   s    		c         C   sÒ   t  | ƒ } t | ƒ rT |  j pN t d g  |  j D] } | j | ƒ ^ q2 ƒ } n- |  j | ƒ p~ |  j j o~ | |  j j k } |  j	 j
 | ƒ } | d k	 r» t j d | | ƒ | } n  t j d | | ƒ | S(   s½   Is the directory a wanted test directory?

        All package directories match, so long as they do not match exclude. 
        All other directories must match test requirements.
        s$   Plugin setting selection of %s to %ss   wantDirectory %s? %sN(   t   op_basenameR   R   R   R
   R   R   R   t   srcDirsR   t   wantDirectoryR$   R%   (   R   t   dirnamet   tailR   R(   R)   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR,   S   s    
,	
	c   
      C   s  t  | ƒ } g  |  j D] } | j | ƒ r | ^ q } | rQ t j d | ƒ t S|  j j r~ t | ƒ r~ t j	 d | ƒ t St
 | ƒ \ } } | d k } | o® |  j | ƒ } |  j j | ƒ }	 |	 d k	 rë t j d | |	 ƒ |	 } n  t j d | | ƒ | S(   s  Is the file a wanted test file?

        The file must be a python source file and match testMatch or
        include, and not match exclude. Files that match ignore are *never*
        wanted, regardless of plugin, testMatch, include or exclude settings.
        s'   %s matches ignoreFiles pattern; skippeds   %s is executable; skippeds   .pys   plugin setting want %s to %ss   wantFile %s? %sN(   R*   R   R   R$   R%   t   FalseR   t
   includeExeR   t   infot   op_splitextR   R   t   wantFileR
   (
   R   t   filet   baset   ignore_thist   ignore_matchest   dummyt   extt   pysrcR(   R)   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR3   k   s&    			c         C   sÁ   y( t  | d ƒ r | j } n	 | j } Wn t k
 r< t SXt | d d ƒ } | d k	 rd | } n | j d ƒ o€ |  j | ƒ } |  j	 j
 | ƒ } | d k	 rª | } n  t j d | | ƒ | S(   s)   Is the function a test function?
        t   compat_func_nameR   R   s   wantFunction %s? %sN(   t   hasattrR;   R   t   AttributeErrorR/   R   R
   R   R   R   t   wantFunctionR$   R%   (   R   t   functiont   funcnameR'   R(   R)   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR>   ‰   s    		c         C   s©   y | j  } Wn t k
 r! t SX| j d ƒ r5 t St | d d ƒ } | d k	 r\ | } n |  j | ƒ } |  j j | ƒ } | d k	 r’ | } n  t	 j
 d | | ƒ | S(   s%   Is the method a test method?
        R   R   s   wantMethod %s? %sN(   R   R=   R/   R   R   R
   R   R   t
   wantMethodR$   R%   (   R   t   methodt   method_nameR'   R(   R)   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyRA   Ÿ   s    		c         C   s“   t  | d d ƒ } | d k	 r' | } n. |  j | j j d ƒ d ƒ pR | j d k } |  j j | ƒ } | d k	 r| | } n  t j d | | ƒ | S(   s˜   Is the module a test module?

        The tail of the module name must match test requirements. One exception:
        we always want __main__.
        R   t   .iÿÿÿÿt   __main__s   wantModule %s? %sN(	   R   R
   R   R   t   splitR   t
   wantModuleR$   R%   (   R   t   moduleR'   R(   R)   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyRG   µ   s    		(   R   t
   __module__t   __doc__R   R   R   R#   R,   R3   R>   RA   RG   (    (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR      s   								c           B   s5   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z RS(   s±  A test address represents a user's request to run a particular
    test. The user may specify a filename or module (or neither),
    and/or a callable (a class, function, or method). The naming
    format for test addresses is:

    filename_or_module:callable

    Filenames that are not absolute will be made absolute relative to
    the working dir.

    The filename or module part will be considered a module name if it
    doesn't look like a file, that is, if it doesn't exist on the file
    system and it doesn't contain any directory separators and it
    doesn't end in .py.

    Callables may be a class name, function name, method name, or
    class.method specification.
    c         C   s>  | d  k r t j ƒ  } n  | |  _ | |  _ t | ƒ \ |  _ |  _ |  _ t	 j
 d | |  j |  j |  j ƒ |  j d  k r© |  j d  k	 r© t |  j |  j ƒ |  _ q© n  |  j rt |  j ƒ |  _ t |  j ƒ sñ t t | |  j ƒ ƒ |  _ n  |  j d  k rt |  j ƒ |  _ qn  t	 j
 d | |  j |  j |  j ƒ d  S(   Ns4   Test name %s resolved to file %s, module %s, call %ss;   Final resolution of test name %s: file %s module %s call %s(   R
   t   ost   getcwdR   t
   workingDirR   t   filenameRH   t   callR$   R%   R   R   t   op_isabst
   op_abspatht   op_joinR   (   R   R   RM   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR   Ý   s(    					c         C   s   |  j  |  j |  j f S(   N(   RN   RH   RO   (   R   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   totupleó   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   __str__ö   s    c         C   s    d |  j  |  j |  j |  j f S(   Ns   %s: (%s, %s, %s)(   R   RN   RH   RO   (   R   (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   __repr__ù   s    N(   R   RI   RJ   R
   R   RS   RT   RU   (    (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyR	   Ê   s
   		("   RJ   t   loggingRK   R!   t   nose.configR    t	   nose.utilR   R   R   R   R   R   t	   getLoggerR   R$   t   __all__t   patht   joinRR   t   basenameR*   t   existst	   op_existst   splitextR2   t   isabsRP   t   abspathRQ   t   objectR   R   R	   (    (    (    s/   /tmp/pip-unpacked-wheel-IhimZu/nose/selector.pyt   <module>   s    .ª