
Xc           @` s  d  d l  m Z m Z m 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 m Z m Z d  d l m Z d  d l m Z d  d l Z d d l m Z d d	 l m Z m Z d
 e j f d     YZ d e j f d     YZ d e
 j f d     YZ e j   Z d e
 j  f d     YZ! d e" f d     YZ# d e f d     YZ$ e$ Z% d e j& j' f d     YZ( d S(   i    (   t   divisiont   absolute_importt   print_functionN(   t   doctests(   t
   ErrorClasst   ErrorClassPlugin(   t   Plugin(   t   srci   (   t   get_package_name(   t   KnownFailureExceptiont   KnownFailureTestt   NumpyDocTestFinderc           B` s   e  Z d    Z d   Z RS(   c         C` s   | d k r t St j |  r/ | j | j k St j |  rN | j | j k St j	 |  rm | j | j k St j
 |  r | j | j j j k St j |  d k	 r | t j |  k St | d  r | j | j k St | t  r t St d   d S(   sY   
        Return true if the given object is defined in the given
        module.
        t
   __module__s"   object must be a class or functionN(   t   Nonet   Truet   inspectt
   isfunctiont   __dict__t   __globals__t	   isbuiltint   __name__R   t   isclasst   ismethodt   __self__t	   __class__t	   getmodulet   hasattrt
   isinstancet   propertyt
   ValueError(   t   selft   modulet   object(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   _from_module   s"    c         C` s  t  j j |  | | | | | | |  d d l m } m }	 m }
 m } m } |
 |  r |  j	 r x| | j
 j   D]h \ } } d | | f } | |  s |	 |  rr |  j | |  rr |  j | | | | | | |  qr qr Wn  |	 |  r|  j	 rx | j
 j   D] \ } } t | t  r3t | |  } n  t | t  rWt | |  j } n  | |  s|	 |  s| |  st | t  r|  j | |  rd | | f } |  j | | | | | | |  qqWn  d S(   sm   
        Find tests for the given object and any contained objects, and
        add them to `tests`.
        i    (   t	   isroutineR   t   ismoduleR   R   s   %s.%sN(   t   doctestt   DocTestFindert   _findR   R"   R   R#   R   R   t   _recurseR   t   itemsR!   R   t   staticmethodt   getattrt   classmethodt   __func__R   (   R   t   testst   objt   nameR   t   source_linest   globst   seenR"   R   R#   R   R   t   valnamet   valt   valname1(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR&   ;   s,    ((   R   R   R!   R&   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR      s   	t   NumpyOutputCheckerc           B` s   e  Z d    Z RS(   c         C` s   t  j j |  | | |  } | s d | k r1 t S| j d d  } | j d d  } x@ d d g D]2 } | j d | d  } | j d | d  } qb Wt  j j |  | | |  } n  | S(   Ns   #randoms   '>s   '<i   i   s   '<i%d't   int(   R$   t   OutputCheckert   check_outputR   t   replace(   R   t   wantt   gott   optionflagst   rett   sz(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR9   m   s    	(   R   R   R9   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR6   l   s   t   NumpyDocTestCasec           B` s#   e  Z d  d d d d d d  Z RS(   i    t   _c         C` sA   | |  _  | |  _ t j j |  | d | d | d | d | d  S(   NR=   t   setUpt   tearDownt   checker(   t   _result_vart	   _nose_objR$   t   DocTestCaset   __init__(   R   t   testR=   RB   RC   RD   R.   t
   result_var(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRH      s    		N(   R   R   R   RH   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR@      s   	t   NumpyDoctestc           B` s~   e  Z d  Z d Z e j e j BZ d d g Z e	 Z
 e Z e Z e j d  Z d   Z d   Z d   Z d   Z d	   Z RS(
   t   numpydoctesti  s   generate_numpy_api.pys   setup.pyc         C` s)   t  j |  | |  t |  _ d  |  _ d  S(   N(   R   t   optionsR   t   doctest_testsR   t   doctest_result_var(   R   t   parsert   env(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRM      s    	c         C` su   t  j |  | |  |  j   |  _ t j   |  _ |  j rq g  | j j D] } | j	 d k rG | ^ qG | j _ n  d  S(   NR$   (
   R   t	   configuret   test_finder_classt   finderR$   t   DocTestParserRP   t   enabledt   pluginsR/   (   R   RM   t   configt   p(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRR      s    	c         C` s   t  t j j | j   } i t d 6d d 6d d 6t d 6| _ d | k r | j d  } | d } t	 | | j i  | g  | j | <n  d	 S(
   s`   Configure `test` object to set test context

        We set the numpy / scipy standard doctest namespace

        Parameters
        ----------
        test : test object
            with ``globs`` dictionary defining namespace

        Returns
        -------
        None

        Notes
        -----
        `test` object modified in place
        t   __builtins__t   __main__t   __file__R   t   npt   scipyt   .iN(
   R   t   ost   patht   dirnamet   filenameRZ   t   numpyR1   t   splitt
   __import__(   R   RI   t   pkg_nameRY   t   p2(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   set_test_context   s    


c      	   c` s   |  j  | j  s) t j j d |  d  Sy |  j j |  } Wn t k
 rS d  SX| s^ d  S| j   t	 | j
  } xk | D]c } | j s q~ n  | j s | | _ n  |  j |  |  j | d |  j d |  j   d |  j Vq~ Wd  S(   Ns   Doctest doesn't want module %sR=   RD   RJ   (   t   matchesR   t   npdt   logt   debugRT   t   findt   AttributeErrort   sortR   R\   t   examplesRc   Ri   t   doctest_case_classt   doctest_optflagst   out_check_classRO   (   R   R   R-   t   module_fileRI   (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   loadTestsFromModule   s*    
			c         C` s   t  j t   d  S(   N(   Rd   t   set_printoptionst   print_state(   R   (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   afterContext  s    c         C` s8   t  j j |  } | |  j k r% t St j j |  |  S(   N(   R`   Ra   t   basenamet   doctest_ignoret   FalseRk   t   Doctestt   wantFile(   R   t   filet   bn(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR~     s    (   R   R   R/   t   scoreR$   t   NORMALIZE_WHITESPACEt   ELLIPSISRs   R{   R@   Rr   R6   Rt   R   RS   R`   t   environRM   RR   Ri   Rv   Ry   R~   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRK      s   				*		t	   Unpluggerc           B` s>   e  Z d  Z d Z e Z d Z d d  Z d   Z d   Z	 RS(   si    Nose plugin to remove named plugin late in loading

    By default it removes the "doctest" plugin.
    t	   unpluggeri  R$   c         C` s   | |  _  d  S(   N(   t	   to_unplug(   R   R   (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRH     s    c         C` s   d  S(   N(    (   R   RP   RQ   (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRM     s    c         C` s;   g  | j  j  D] } | j |  j k r | ^ q | j  _  d  S(   N(   RW   R/   R   (   R   RM   RX   RY   (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRR     s    (
   R   R   t   __doc__R/   R   RV   R   RH   RM   RR   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR     s   	t   KnownFailurePluginc           B` sD   e  Z d  Z e Z e e d d d e Z e	 j
 d  Z d   Z RS(   s1  Plugin that installs a KNOWNFAIL error class for the
    KnownFailureClass exception.  When KnownFailure is raised,
    the exception will be logged in the knownfail attribute of the
    result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the
    exception will not be counted as an error or failure.t   labelt	   KNOWNFAILt	   isfailurec      
   C` s;   d } | j  d d d d d d | j | t  d d	 d  S(
   Nt   NOSE_WITHOUT_KNOWNFAILs   --no-knownfailt   actiont
   store_truet   destt   noKnownFailt   defaultt   helps3   Disable special handling of KnownFailure exceptions(   t
   add_optiont   getR|   (   R   RP   RQ   t   env_opt(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRM   .  s    c         C` s>   |  j  s d  S| |  _ t | d t  } | r: t |  _ n  d  S(   NR   (   t   can_configuret   confR*   R|   RV   (   R   RM   R   t   disable(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyRR   5  s    		(   R   R   R   R   RV   R   R	   R|   t	   knownfailR`   R   RM   RR   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR   #  s   		t   NumpyTestProgramc           B` s   e  Z d    Z RS(   c         C` s   |  j  d k rE t j j d |  j j d |  j j d |  j  |  _  n  |  j j j	 |  j   } | d k	 ru | |  _  n  |  j  j
 |  j  |  _ |  j j   |  _ |  j S(   s  Run Tests. Returns true on success, false on failure, and
        sets self.success to the same value.

        Because nose currently discards the test result object, but we need
        to return it to the user, override TestProgram.runTests to retain
        the result
        t   streamt	   verbosityRX   N(   t
   testRunnerR   t   noset   coret   TextTestRunnerRX   R   R   RW   t   prepareTestRunnert   runRI   t   resultt   wasSuccessfult   success(   R   t   plug_runner(    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   runTestsC  s    (   R   R   R   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyR   B  s   ()   t
   __future__R    R   R   R`   R$   R   R   t   nose.pluginsR   Rk   t   nose.plugins.errorclassR   R   t   nose.plugins.baseR   t	   nose.utilR   Rd   t
   nosetesterR   t   utilsR	   R
   R%   R   R8   R6   RG   R@   t   get_printoptionsRx   R}   RK   R    R   R   t   KnownFailureR   t   TestProgramR   (    (    (    s8   /tmp/pip-build-2Vcwy8/numpy/numpy/testing/noseclasses.pyt   <module>   s(   	Ox