ó
¢áSc           @` 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 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 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" d e f d „  ƒ  YZ# 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_namet   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(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/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(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyR$   B   s,    ((   R   R
   R   R$   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/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(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyR7   w   s    	(   R   R
   R7   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyR4   v   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;   R@   RA   RB   R,   t
   result_var(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRF   ”   s    		N(   R   R
   R   RF   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/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(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRK   ±   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   DocTestParserRN   t   enabledt   pluginsR-   (   R   RK   t   configt   p(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRP   º   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   .iÿÿÿÿN(
   R   t   ost   patht   dirnamet   filenameRX   t   numpyR/   t   splitt
   __import__(   R   RG   t   pkg_nameRW   t   p2(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/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;   RB   RH   (   t   matchesR   t   npdt   logt   debugRR   t   findt   AttributeErrort   sortR   RZ   t   examplesRa   Rg   t   doctest_case_classt   doctest_optflagst   out_check_classRM   (   R   R   R+   t   module_fileRG   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyt   loadTestsFromModuleñ   s*    
			c         C` s   t  j t �  d  S(   N(   Rb   t   set_printoptionst   print_state(   R   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyt   afterContext  s    c         C` s8   t  j j | ƒ } | |  j k r% t St j j |  | ƒ S(   N(   R^   R_   t   basenamet   doctest_ignoret   FalseRi   t   Doctestt   wantFile(   R   t   filet   bn(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyR|     s    (   R   R
   R-   t   scoreR"   t   NORMALIZE_WHITESPACEt   ELLIPSISRq   Ry   R>   Rp   R4   Rr   R	   RQ   R^   t   environRK   RP   Rg   Rt   Rw   R|   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRI       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…   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRF   !  s    c         C` s   d  S(   N(    (   R   RN   RO   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRK   $  s    c         C` s;   g  | j  j  D] } | j |  j k r | ^ q | j  _  d  S(   N(   RU   R-   R…   (   R   RK   RV   RW   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRP   '  s    (
   R   R
   t   __doc__R-   R   RT   R   RF   RK   RP   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRƒ     s   	t   KnownFailureTestc           B` s   e  Z d  Z RS(   s<   Raise this exception to mark a test as a known failing test.(   R   R
   R†   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyR‡   -  s   t   KnownFailurec           B` sD   e  Z d  Z e Z e e d d d e ƒZ e	 j
 d „ Z d „  Z RS(   s5  Plugin that installs a KNOWNFAIL error class for the
    KnownFailureClass exception.  When KnownFailureTest 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   helps7   Disable special handling of KnownFailureTest exceptions(   t
   add_optiont   getRz   (   R   RN   RO   t   env_opt(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRK   =  s    c         C` s>   |  j  s d  S| |  _ t | d t ƒ } | r: t |  _ n  d  S(   NR�   (   t   can_configuret   confR(   Rz   RT   (   R   RK   R—   t   disable(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRP   D  s    		(   R   R
   R†   R   RT   R   R‡   Rz   t	   knownfailR^   R‚   RK   RP   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRˆ   2  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	   verbosityRV   N(   t
   testRunnerR   t   noset   coret   TextTestRunnerRV   R›   Rœ   RU   t   prepareTestRunnert   runRG   t   resultt   wasSuccessfult   success(   R   t   plug_runner(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyt   runTestsP  s    (   R   R
   R§   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyRš   O  s   ('   t
   __future__R    R   R   R^   R"   Rž   t   nose.pluginsR   Ri   t   nose.plugins.errorclassR   R   t   nose.plugins.baseR   t	   nose.utilR   Rb   t
   nosetesterR   R   R#   R	   R6   R4   RE   R>   t   get_printoptionsRv   R{   RI   R   Rƒ   t	   ExceptionR‡   Rˆ   RŸ   t   TestProgramRš   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/testing/noseclasses.pyt   <module>   s&   [x