ó
J9•Qc           @   sw  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 d d l m Z d d l m Z m Z m Z d d l m Z d d l m Z d d	 l m Z m Z e j d
 ƒ Z e j d k Z d d d d d d d g Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ e Z Z  d „  Z! d d „ Z" d „  Z# e$ d k rse  ƒ  n  d S(   s,   Implements nose test program and collector.
iÿÿÿÿ(   t
   generatorsN(   t   Configt   all_config_files(   t   defaultTestLoader(   t   PluginManagert   DefaultPluginManagert   RestrictedPluginManager(   t   TextTestResult(   t   FinalizingSuiteWrapper(   t   isclasst   tolists	   nose.corei   i   t   TestProgramt   maint   runt   run_exitt	   runmodulet	   collectort   TextTestRunnerc           B   s8   e  Z d  Z e j d d d d „ Z d „  Z d „  Z RS(   sÉ   Test runner that uses nose's TextTestResult to enable errorClasses,
    as well as providing hooks for plugins to override or replace the test
    output stream, results, and the test case itself.
    i   c         C   s>   | d  k r t ƒ  } n  | |  _ t j j |  | | | ƒ d  S(   N(   t   NoneR   t   configt   unittestR   t   __init__(   t   selft   streamt   descriptionst	   verbosityR   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR       s    	c         C   s   t  |  j |  j |  j |  j ƒ S(   N(   R   R   R   R   R   (   R   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyt   _makeResult(   s    	c         C   s¹   |  j  j j | ƒ } | d k	 r* | } n  |  j  j j |  j ƒ } | d k	 rZ | |  _ n  |  j ƒ  } t j ƒ  } | | ƒ t j ƒ  } | j ƒ  | j	 | | ƒ |  j  j j
 | ƒ | S(   sa   Overrides to provide plugin hooks and defer all output to
        the test result class.
        N(   R   t   pluginst   prepareTestR   t   setOutputStreamR   R   t   timet   printErrorst   printSummaryt   finalize(   R   t   testt   wrappert   wrappedt   resultt   startt   stop(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   .   s    	

N(	   t   __name__t
   __module__t   __doc__t   syst   stderrR   R   R   R   (    (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR      s
   	c           B   sƒ   e  Z d  Z d Z d
 d d
 d
 d
 d
 d
 d
 e d
 d
 d „ Z d
 d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z e e ƒ Z RS(   s¾  Collect and run tests, returning success or failure.

    The arguments to TestProgram() are the same as to
    :func:`main()` and :func:`run()`:

    * module: All tests are in this module (default: None)
    * defaultTest: Tests to load (default: '.')
    * argv: Command line arguments (default: None; sys.argv is read)
    * testRunner: Test runner instance (default: None)
    * testLoader: Test loader instance (default: None)
    * env: Environment; ignored if config is provided (default: None;
      os.environ is read)
    * config: :class:`nose.config.Config` instance (default: None)
    * suite: Suite or list of tests to run (default: None). Passing a
      suite or lists of tests will bypass all test discovery and
      loading. *ALSO NOTE* that if you pass a unittest.TestSuite
      instance as the suite, context fixtures at the class, module and
      package level will not be used, and many plugin hooks will not
      be called. If you want normal nose behavior, either pass a list
      of tests, or a fully-configured :class:`nose.suite.ContextSuite`.
    * exit: Exit after running tests and printing report (default: True)
    * plugins: List of plugins to use; ignored if config is provided
      (default: load plugins with DefaultPluginManager)
    * addplugins: List of **extra** plugins to use. Pass a list of plugin
      instances in this argument to make custom plugins available while
      still using the DefaultPluginManager.
    i   t   .c         C   sà   | d  k r t j } n  | d  k r9 |  j | |
 ƒ } n  | rU | j j d | ƒ n  | |  _ | |  _ |	 |  _ i  } t	 j
 d d !} | d k r« | d k r« |	 | d <n  t j j |  d | d | d	 | d
 | d | | d  S(   Nt   extrapluginsi    i   i   i   t   exitt   modulet   defaultTestt   argvt
   testRunnert
   testLoader(   i   i   (   i   i    (   R   t   ost   environt
   makeConfigR   t
   addPluginsR   t   suiteR/   R+   t   version_infoR   R   R   (   R   R0   R1   R2   R3   R4   t   envR   R9   R/   R   t
   addpluginst
   extra_argst   version(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   c   s"    				c         C   sC   t  ƒ  } | r! t d | ƒ } n	 t ƒ  } t d | d | d | ƒ S(   sS   Load a Config, pre-filled with user config files if any are
        found.
        R   R;   t   files(   R   R   R   R   (   R   R;   R   t	   cfg_filest   manager(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR7   x   s    		c         C   sÕ  |  j  j | d |  j ƒ  ƒt j d |  j  ƒ |  j  j j rŒ d d l m } t	 j
 t	 _ d t j j t	 j d ƒ | f GHt	 j d ƒ n  |  j  j j rµ |  j ƒ  t	 j d ƒ n  |  j d k rÜ t d |  j  ƒ |  _ n* t |  j ƒ r|  j d |  j  ƒ |  _ n  |  j  j j |  j ƒ } | d k	 r6| |  _ n  t j d |  j ƒ |  j  j rg|  j  j |  _ n t |  j ƒ |  _ t j d	 |  j ƒ t j d
 |  j ƒ |  j  j d k	 rÇt j |  j  j ƒ n  |  j ƒ  d S(   s>   Parse argv and env and configure running environment.
        t   docs   configured %siÿÿÿÿ(   t   __version__s   %s version %si    R   s   test loader is %ss   defaultTest %ss   Test names are %sN(   R   t	   configuret   usaget   logt   debugt   optionsR>   t   noseRC   R+   t
   __stdout__t   stdoutR5   t   patht   basenameR2   R/   t   showPluginsR4   R   R   R	   R   t   prepareTestLoadert	   testNamesR
   R1   t
   workingDirt   chdirt   createTests(   R   R2   RC   t   plug_loader(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyt	   parseArgs„   s4    "
c         C   sY   t  j d |  j ƒ |  j d k	 r= |  j j |  j ƒ |  _ n |  j j |  j ƒ |  _ d S(   sÑ   Create the tests to run. If a self.suite
        is set, then that suite will be used. Otherwise, tests will be
        loaded from the given test names (self.testNames) using the
        test loader.
        s   createTests called with %sN(	   RF   RG   R9   R   R4   t
   suiteClassR"   t   loadTestsFromNamesRP   (   R   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyRS   «   s    c         C   sÄ   t  j d ƒ |  j d k rL t d |  j j d |  j j d |  j ƒ |  _ n  |  j j j	 |  j ƒ } | d k	 r| | |  _ n  |  j j
 |  j ƒ } | j ƒ  |  _ |  j r½ t j |  j ƒ n  |  j S(   so   Run Tests. Returns true on success, false on failure, and sets
        self.success to the same value.
        s   runTests calledR   R   R   N(   RF   RG   R3   R   R   R   R   R   R   t   prepareTestRunnerR   R"   t   wasSuccessfult   successR/   R+   (   R   t   plug_runnerR%   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyt   runTests¹   s    	c      	   C   sH  d d l  } d d d „  ƒ  Y} |  j j } |  j j j ƒ  x|  j j D]ø } d | j GH| d k rH d | j GHd j | j | j	 ƒ  j
 ƒ  d	 d
 d d
 ƒƒ GH| d k r<| ƒ  } | j | ƒ t | j ƒ r<Hd GHx^ | j D]P \ } } d d j | ƒ GH| râ d j | j | j
 ƒ  d	 d d d ƒƒ GHqâ qâ Wq<n  HqH qH Wd S(   s)   Print list of available plugins.
        iÿÿÿÿNt   DummyParserc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   g  |  _  d  S(   N(   RH   (   R   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   Ñ   s    c         _   s&   |  j  j | | j d d ƒ f ƒ d  S(   Nt   helpt    (   RH   t   appendt   pop(   R   t   argt   kw(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyt
   add_optionÓ   s    (   R(   R)   R   Rd   (    (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR]   Ð   s   	s	   Plugin %si   s     score: %ss   
t   initial_indents     t   subsequent_indenti   s
     Options:s     %ss   , s       (    (   t   textwrapR   R   R   t   sortt   namet   scoret   joint   wrapR^   t   stript
   addOptionst   lenRH   (   R   Rg   R]   t   vt   pt   parsert   optsR^   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyRN   Ë   s2    	c         C   sÄ   d d  l  } y7 | j } | j t j j t j j t ƒ d ƒ ƒ } WnY t k
 rž t	 t j j t j j t ƒ d ƒ d ƒ } z | j
 ƒ  } Wd  | j ƒ  Xn Xt | t ƒ sÀ | j d ƒ } n  | S(   Niÿÿÿÿs	   usage.txtt   rs   utf-8(   RI   t
   __loader__t   get_dataR5   RL   Rk   t   dirnamet   __file__t   AttributeErrort   opent   readt   closet
   isinstancet   strt   decode(   t   clsRI   t   ldt   textt   f(    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyRE   î   s    	N(   R(   R)   R*   R   R   t   TrueR   R7   RU   RS   R\   RN   RE   t   classmethod(    (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   E   s   		'			#	c          O   s   t  | d <t |  | Ž  j S(   s¢  Collect and run tests, returning success or failure.

    The arguments to `run()` are the same as to `main()`:

    * module: All tests are in this module (default: None)
    * defaultTest: Tests to load (default: '.')
    * argv: Command line arguments (default: None; sys.argv is read)
    * testRunner: Test runner instance (default: None)
    * testLoader: Test loader instance (default: None)
    * env: Environment; ignored if config is provided (default: None;
      os.environ is read)
    * config: :class:`nose.config.Config` instance (default: None)
    * suite: Suite or list of tests to run (default: None). Passing a
      suite or lists of tests will bypass all test discovery and
      loading. *ALSO NOTE* that if you pass a unittest.TestSuite
      instance as the suite, context fixtures at the class, module and
      package level will not be used, and many plugin hooks will not
      be called. If you want normal nose behavior, either pass a list
      of tests, or a fully-configured :class:`nose.suite.ContextSuite`.
    * plugins: List of plugins to use; ignored if config is provided
      (default: load plugins with DefaultPluginManager)
    * addplugins: List of **extra** plugins to use. Pass a list of plugin
      instances in this argument to make custom plugins available while
      still using the DefaultPluginManager.

    With the exception that the ``exit`` argument is always set
    to False.
    R/   (   t   FalseR   RZ   (   Rb   Rc   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR     s    
t   __main__c         K   s   t  d |  |  d S(   sª   Collect and run tests in a single module only. Defaults to running
    tests in __main__. Additional arguments to TestProgram may be passed
    as keyword arguments.
    R1   N(   R   (   Ri   Rc   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   &  s    c          C   s‰   d }  t  d |  ƒ } t d t ƒ  d | ƒ } | j d	 d
 g ƒ t | ƒ } | j rj | j | j ƒ } n | j d ƒ } t | | j ƒ S(   s  TestSuite replacement entry point. Use anywhere you might use a
    unittest.TestSuite. The collector will, by default, load options from
    all config files and execute loader.loadTestsFromNames() on the
    configured testNames, or '.' if no testNames are configured.
    t   reportR   RO   RX   R   t   excludeR?   R   R2   R   R-   (   Rˆ   s   prepareTests   prepareTestLoaders   prepareTestRunners   setOutputStream(   R-   (	   R   R   R   RD   R   RP   RW   R   R!   (   t   setuptools_incompatR   t   conft   loaderR9   (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyR   .  s    
  		(   i   i   (%   R*   t
   __future__R    t   loggingR5   R+   R   R   t   nose.configR   R   t   nose.loaderR   t   nose.plugins.managerR   R   R   t   nose.resultR   t
   nose.suiteR   t	   nose.utilR	   R
   t	   getLoggerRF   R:   t	   compat_24t   __all__R   R   R   R   R   R   R   R(   (    (    (    s-   /sys/lib/python2.7/site-packages/nose/core.pyt   <module>   s0   	*½
	!	