
NXc           @  s  d  Z  d d l m Z d d l Z d d l m Z d d l Z d d l j Z d d l	 Z	 d d l
 m Z m Z m Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l  m! Z! m" Z" e j# Z$ e j% d d e&  e j% d d e&  e j% d d e'  d   Z( d   Z) d e) d  Z+ i  Z, e+ d  e, d <e+ d  e, d <e+ d  e, d <d d d d d d g Z- d e. f d      YZ/ d!   e- D Z0 e0 d Z1 e, d s+e1 j2 d"  e1 j2 d#  n  e, d sUe1 j2 d$  f e1 j2 d%  n  e0 d Z1 e1 j2 d&  e, d se1 j2 d'  n  e1 j2 d(  e1 j2 d)  e1 j2 d*  e0 d Z1 e	 j3 d+ k re1 j2 d,  e1 j2 d-  n  e0 d j2 d.  e0 d Z1 e1 j2 d/  e1 j2 d0  e1 j2 d1  e/ d0 d2 d3 g  e0 d0 <e- j4 d0  d4   Z5 d5 e f d6     YZ6 d7 e f d8     YZ7 d9 e f d:     YZ8 d;   Z9 e: d< k re9   n  d S(=   sN  IPython Test Suite Runner.

This module provides a main entry point to a user script to test IPython
itself from the command line. There are two ways of running this script:

1. With the syntax `iptest all`.  This runs our entire test suite by
   calling this script (with different arguments) recursively.  This
   causes modules and package to be tested in different processes, using nose
   or trial where appropriate.
2. With the regular nose syntax, like `iptest -vvs IPython`.  In this form
   the script simply calls nose, but with special command line flags and
   plugins loaded.

i(   t   print_functionN(   t   BytesIO(   t   Threadt   Lockt   Event(   t   Xunit(   t   SkipTest(   t   TestProgram(   t   Plugin(   t   safe_str(   t   bytes_to_str(   t   import_item(   t   IPythonDoctest(   t   KnownFailuret   knownfailureift   ignores   the sets module is deprecateds   the sha module is deprecateds*   wxPython/wxWidgets release number mismatchc            sg   y t  t  d      Wn t k
 r; }  t |     n Xd    f d  } t j t _ | t _ d  S(   Nc           S  s   d  S(   N(   t   None(    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   <lambda>B   s    c           s:   t  | d    r' t f | d } n  |  j | | |  S(   Ni    i   (   t
   issubclassR   t   orig_addError(   t   selft   testt   errt   capt(   t   KnownFailureTest(    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   addErrorF   s    (   R   t   Truet	   Exceptiont   typeR   R   R   R   (   t   eR   (    (   R   sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   monkeypatch_xunit@   s    c         C  s   |  j  S(   N(   t   __version__(   t   mod(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   extract_versionQ   s    c         C  sX   y t  |   } Wn t t f k
 r* t SX| rP | rF | |  } n  | | k St Sd S(   s  Test to see if item is importable, and optionally check against a minimum
    version.

    If min_version is given, the default behavior is to check against the
    `__version__` attribute of the item, but specifying `callback` allows you to
    extract the value you are interested in. e.g::

        In [1]: import sys

        In [2]: from IPython.testing.iptest import test_for

        In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
        Out[3]: True

    N(   R   t   ImportErrort   RuntimeErrort   FalseR   (   t   itemt   min_versiont   callbackt   check(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   test_forT   s    
t
   matplotlibt   pygmentst   sqlite3t   coret
   extensionst   libt   terminalt   testingt   utilst   TestSectionc           B  s2   e  Z d    Z d   Z d   Z e d    Z RS(   c         C  s1   | |  _  | |  _ g  |  _ g  |  _ t |  _ d  S(   N(   t   namet   includest   excludest   dependenciesR   t   enabled(   R   R4   R5   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   __init__   s
    				c         C  sJ   | j  d  s' |  j d d | } n  |  j j | j d t j   d  S(   Nt   IPythoni    t   .(   t
   startswithR5   R6   t   appendt   replacet   ost   sep(   R   t   module(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   exclude   s    c         G  s   |  j  j |  d  S(   N(   R7   t   extend(   R   t   packages(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   requires   s    c         C  s    |  j  o t d   |  j D  S(   Nc         s  s   |  ] } t  | Vq d  S(   N(   t   have(   t   .0t   p(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pys	   <genexpr>   s    (   R8   t   allR7   (   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   will_run   s    (   t   __name__t
   __module__R9   RB   RE   t   propertyRJ   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR3      s   			c         C  s)   i  |  ] } t  | d  | g  |  q S(   s
   IPython.%s(   R3   (   RG   t   n(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pys
   <dictcomp>   s   	 s   tests.test_historyt   historyt
   pylabtoolss   tests.test_pylabtoolst   kernels   tests.test_lexerst   inputhookgtkt   inputhookwxt	   inputhookt   win32s   plugin.test_exampleips   plugin.dtexamplet   consolet   rmagict
   autoreloads   tests.test_autoreloads   IPython.extensions.autoreloads(   IPython.extensions.tests.test_autoreloadc          C  s   d d l  m }  d d l m } t j j |     } xi t D]a } xX | j D]M } t	 | |  } t j j
 |  rL t j | d  rL | d |  qL qL Wq< Wd  S(   Ni(   t   get_ipython_package_dir(   t   warns   .*s   Excluding nonexistent file: %r(   t   IPython.pathsRY   t   IPython.utils.warnRZ   R?   t   patht   dirnamet   test_sectionst
   exclusionst   pjoint   existst   glob(   RY   RZ   t   parentt   sect   patternt   fullpath(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   check_exclusions_exist   s    't   ExclusionPluginc           B  sP   e  Z d  Z d Z d Z d d  Z e j d  Z	 d   Z
 d   Z d   Z RS(	   sE   A nose plugin to effect our exclusions of files and directories.
    R`   i  c         C  s&   | p	 g  |  _  t t |   j   d S(   s   
        Parameters
        ----------

        exclude_patterns : sequence of strings, optional
          Filenames containing these patterns (as raw strings, not as regular
          expressions) are excluded from the tests.
        N(   t   exclude_patternst   superRi   R9   (   R   Rj   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR9      s    	c         C  s   t  j |  | |  d  S(   N(   R   t   options(   R   t   parsert   env(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyRl      s    c         C  s    t  j |  | |  t |  _ d  S(   N(   R   t	   configureR   R8   (   R   Rl   t   config(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyRo      s    c           s'   t    f d   |  j D  r# t Sd S(   sG   Return whether the given filename should be scanned for tests.
        c         3  s   |  ] } |   k Vq d  S(   N(    (   RG   t   pat(   t   filename(    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pys	   <genexpr>   s    N(   t   anyRj   R$   R   (   R   Rr   (    (   Rr   sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   wantFile   s    c           s'   t    f d   |  j D  r# t Sd S(   sH   Return whether the given directory should be scanned for tests.
        c         3  s   |  ] } |   k Vq d  S(   N(    (   RG   Rq   (   t	   directory(    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pys	   <genexpr>  s    N(   Rs   Rj   R$   R   (   R   Ru   (    (   Ru   sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   wantDirectory   s    N(   RK   RL   t   __doc__R4   t   scoreR   R9   R?   t   environRl   Ro   Rt   Rv   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyRi      s   		t   StreamCapturerc           B  sM   e  Z e Z e Z e d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   c         C  se   t  t |   j   | |  _ g  |  _ t   |  _ t j   \ |  _	 |  _
 t   |  _ t   |  _ d  S(   N(   Rk   Rz   R9   t   echot   streamsR   t   bufferR?   t   pipet   readfdt   writefdR   t   buffer_lockR   t   stop(   R   R{   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR9   
  s    		c         C  s   t  |  _ xj |  j j   su t j |  j d  } |  j  |  j j	 |  Wd  QX|  j
 r t j j	 t |   q q Wt j |  j  t j |  j  d  S(   Ni   (   R   t   startedR   t   is_setR?   t   readR   R   R}   t   writeR{   t   syst   stdoutR
   t   closeR   (   R   t   chunk(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   run  s    	
	c         C  s4   |  j  % |  j j d  |  j j d  Wd  QXd  S(   Ni    (   R   R}   t   truncatet   seek(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   reset_buffer!  s    
c         C  s!   |  j   |  j j   SWd  QXd  S(   N(   R   R}   t   getvalue(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt
   get_buffer&  s    
c         C  s   |  j  s |  j   n  d  S(   N(   R   t   start(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   ensure_started*  s    	c         C  s;   |  j  s d S|  j j   t j |  j d  |  j   d S(   s   Safely stop the thread.Nt    (   R   R   t   setR?   R   R   t   join(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   halt.  s
    	(   RK   RL   R   t   daemonR$   R   R9   R   R   R   R   R   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyRz     s   					t   SubprocessStreamCapturePluginc           B  sJ   e  Z d  Z d   Z d   Z d   Z d   Z d   Z e Z d   Z	 RS(   t   subprocstreamsc         C  sA   t  j |   t   |  _ t j j d d  |  _ |  j t	 _
 d  S(   Nt   IPTEST_SUBPROC_STREAMSt   capture(   R   R9   Rz   t   stream_capturerR?   Ry   t   gett   destinationt   get_write_filenot   noset   iptest_stdstreams_fileno(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR9   9  s    c         C  s\   |  j  d k r& |  j j   |  j j S|  j  d k rK t j t j t j  St j	 j
   Sd  S(   NR   t   discard(   R   R   R   R   R?   t   opent   devnullt   O_WRONLYR   t
   __stdout__t   fileno(   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR   A  s    
c         C  s2   t  j |  | |  |  j d k r. t |  _ n  d  S(   NR   (   R   Ro   R   R   R8   (   R   Rl   Rp   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyRo   J  s    c         C  s   |  j  j   d  S(   N(   R   R   (   R   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt	   startTestP  s    c         C  sn   | \ } } } |  j  j   j d d  } | j   rj t |  } | d | d g } | d j |  | f S| S(   Ns   utf-8R>   s&   >> begin captured subprocess output <<s$   >> end captured subprocess output <<s   
(   R   R   t   decodet   stripR	   R   (   R   R   R   t   ect   evt   tbt   capturedt   out(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   formatFailureT  s    	c         C  s   |  j  j   d  S(   N(   R   R   (   R   t   result(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   finalizec  s    (
   RK   RL   R4   R9   R   Ro   R   R   t   formatErrorR   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyR   7  s   						c          C  s  d t  j k r) t t d  r) t   n  t j d d  t  j d }  |  t k rr t |  } | j t  j d d +nX |  j	 d  r |  d t k r t |  d } | j t  j d d +n t
 |  d	 |  g } t  j d
 d g } d | k rd | k r| d d g } n  t j d k r'| j d  n  t | j  t   t   g } | j j	 d  r| j t    | j d d d g  n  d t j k rt j t j d  n  d | j k rd d l m } | j   n  t d | d |  d S(   s   Run the IPython test suite using nose.

    This function is called when this script is **not** called with the form
    `iptest all`.  It simply calls nose with appropriate command line flags
    and accepts all of the standard nose arguments.
    s   --with-xunitR   R   s<   This will be removed soon.  Use IPython.testing.util insteadi   i   s   IPython.i   R5   s   --detailed-errorss   --exes   -as   -As   !crashs   0.11s   --traverse-namespaceR-   s   IPython.cores   --with-ipdoctests   --ipdoctest-testss   --ipdoctest-extension=txtt   IPTEST_WORKING_DIRs   kernel.inprocessi(   t   globalipappt   argvt
   addpluginsN(   s   cores   IPython.core(   R   R   t   hasattrR   R   t   warningst   filterwarningsR_   R5   R<   R3   R   R   R=   Ri   R6   R   R   R4   R   RC   R?   Ry   t   chdirt   IPython.testingR   t   start_ipythonR   (   t   arg1t   sectionR   t   pluginsR   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt
   run_iptestg  s@    
	
	
		t   __main__(;   Rw   t
   __future__R    Rc   t   ioR   R?   t   os.pathR]   R   t	   threadingR   R   R   R   t   nose.plugins.builtinR   t   nose.plugins.xunitR   R   t	   nose.coreR   t   nose.pluginsR   t	   nose.utilR	   t   IPython.utils.py3compatR
   t   IPython.utils.importstringR   t    IPython.testing.plugin.ipdoctestR   t   IPython.external.decoratorsR   R   R   Ra   R   t   DeprecationWarningt   UserWarningR   R!   R   R)   RF   t   test_group_namest   objectR3   R_   Re   RB   t   platformR=   Rh   Ri   Rz   R   R   RK   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/iptest.pyt   <module>   s   			"






	)00	O