ó
8Þ	Pc           @   s”   d  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 e	 Z
 d Z d Z d Z d	 Z d
 Z d e f d „  ƒ  YZ e Z d S(   s   Unittest main programiÿÿÿÿNi   (   t   loadert   runner(   t   installHandlers)     -f, --failfast   Stop on first failure
s7     -c, --catch      Catch control-C and display results
s=     -b, --buffer     Buffer stdout and stderr during test runs
s»  Usage: %(progName)s [options] [tests]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s test_module               - run tests from test_module
  %(progName)s module.TestClass          - run tests from module.TestClass
  %(progName)s module.Class.test_method  - run specified test method

[tests] can be a list of any number of test modules, classes and test
methods.

Alternative Usage: %(progName)s discover [options]

Options:
  -v, --verbose    Verbose output
%(failfast)s%(catchbreak)s%(buffer)s  -s directory     Directory to start discovery ('.' default)
  -p pattern       Pattern to match test files ('test*.py' default)
  -t directory     Top level directory of project (default to
                   start directory)

For test discovery all test modules must be importable from the top
level directory of the project.
s1  Usage: %(progName)s [options] [test] [...]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s                               - run default set of tests
  %(progName)s MyTestSuite                   - run suite 'MyTestSuite'
  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething
  %(progName)s MyTestCase                    - run all 'test*' test methods
                                               in MyTestCase
t   TestProgramc           B   s†   e  Z d  Z e Z d	 Z Z Z Z	 d d	 d	 d	 e
 j e d d	 d	 d	 d „
 Z d	 d „ Z d „  Z d „  Z e
 j d „ Z d „  Z RS(
   s   A command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    t   __main__i   c         C   sñ   t  | t ƒ rT t | ƒ |  _ x< | j d ƒ d D] } t |  j | ƒ |  _ q2 Wn	 | |  _ | d  k ru t j } n  | |  _	 | |  _
 |	 |  _ | |  _ |
 |  _ | |  _ | |  _ | |  _ t j j | d ƒ |  _ |  j | ƒ |  j ƒ  d  S(   Nt   .i   i    (   t
   isinstancet
   basestringt
   __import__t   modulet   splitt   getattrt   Nonet   syst   argvt   exitt   failfastt
   catchbreakt	   verbosityt   buffert   defaultTestt
   testRunnert
   testLoadert   ost   patht   basenamet   progNamet	   parseArgst   runTests(   t   selfR	   R   R   R   R   R   R   R   R   R   t   part(    (    s#   /usr/lib/python2.7/unittest/main.pyt   __init__H   s$    									c         C   s¤   | r | GHn  i |  j  d 6d d 6d d 6d d 6} |  j t k rO t | d <n  |  j t k rk t | d <n  |  j t k r‡ t | d <n  |  j | GHt	 j
 d ƒ d  S(   NR   t    R   R   R   i   (   R   R   t   Falset   FAILFASTR   t
   CATCHBREAKR   t   BUFFEROUTPUTt   USAGER   R   (   R   t   msgt   usage(    (    s#   /usr/lib/python2.7/unittest/main.pyt	   usageExita   s    
c   	      C   s  t  | ƒ d k r= | d j ƒ  d k r= |  j | d ƒ d  Sd d  l } d d d d d	 d
 g } y}| j | d d | ƒ \ } } xÛ | D]Ó \ } } | d k r¯ |  j ƒ  n  | d k rÇ d |  _ n  | d k rß d |  _ n  | d k r	|  j d  k r	t |  _ q	n  | d k r3|  j	 d  k r3t |  _	 q3n  | d  k rŠ |  j
 d  k r]t |  _
 q]qŠ qŠ Wt  | ƒ d k rŽ|  j d  k rŽd  |  _ nE t  | ƒ d k rÄ| |  _ t d k rÓd  |  _ qÓn |  j f |  _ |  j ƒ  Wn# | j k
 r} |  j | ƒ n Xd  S(!   Ni   t   discoveri   iÿÿÿÿt   helpt   verboset   quietR   t   catchR   t   hHvqfcbs   -hs   -Hs   --helps   -qs   --quieti    s   -vs	   --verboses   -fs
   --failfasts   -cs   --catchs   -bs   --bufferR   (   s   -hs   -Hs   --help(   s   -qs   --quiet(   s   -vs	   --verbose(   s   -fs
   --failfast(   s   -cs   --catch(   s   -bs   --buffer(   t   lent   lowert   _do_discoveryt   getoptR(   R   R   R   t   TrueR   R   R   t	   testNamest   __name__R	   t   createTestst   error(	   R   R   R2   t	   long_optst   optionst   argst   optt   valueR&   (    (    s#   /usr/lib/python2.7/unittest/main.pyR   o   sB    (!	c         C   sL   |  j  d  k r* |  j j |  j ƒ |  _ n |  j j |  j  |  j ƒ |  _ d  S(   N(   R4   R   R   t   loadTestsFromModuleR	   t   testt   loadTestsFromNames(   R   (    (    s#   /usr/lib/python2.7/unittest/main.pyR6   ™   s    c         C   sƒ  d |  j  |  _  d d  l } | j ƒ  } |  j  | _ | j d d d d d t d d	 d
 d ƒ|  j t k r– | j d d d d d t d d d
 d ƒn  |  j t k rÐ | j d d d d d t d d d
 d ƒn  |  j t k r
| j d d d d d t d d d
 d ƒn  | j d d d d d d d d ƒ| j d d d d d d  d d! ƒ| j d" d# d d$ d d  d d% ƒ| j
 | ƒ \ } } t | ƒ d& k r¤|  j ƒ  n  x- t d( | ƒ D] \ } } t | | | ƒ q´W|  j d  k rò| j |  _ n  |  j d  k r| j |  _ n  |  j d  k r.| j |  _ n  | j rCd' |  _ n  | j }	 | j }
 | j } | ƒ  } | j |	 |
 | ƒ |  _ d  S()   Ns   %s discoveriÿÿÿÿs   -vs	   --verboset   destR+   t   defaultR*   s   Verbose outputt   actiont
   store_trues   -fs
   --failfastR   s   Stop on first fail or errors   -cs   --catchR   s'   Catch ctrl-C and display results so fars   -bs   --bufferR   s%   Buffer stdout and stderr during testss   -ss   --start-directoryt   startR   s*   Directory to start discovery ('.' default)s   -ps	   --patternt   patterns   test*.pys+   Pattern to match tests ('test*.py' default)s   -ts   --top-level-directoryt   tops<   Top level directory of project (defaults to start directory)i   i   (   s   starts   patterns   top(   R   t   optparset   OptionParsert   progt
   add_optionR!   R   R   R   R   t
   parse_argsR/   R(   t   zipt   setattrR+   R   RD   RE   RF   R)   R>   (   R   R   t   LoaderRG   t   parserR9   R:   t   nameR<   t	   start_dirRE   t   top_level_dirR    (    (    s#   /usr/lib/python2.7/unittest/main.pyR1       sT    


					c         C   sß   |  j  r t ƒ  n  |  j d  k r1 t j |  _ n  t |  j t t j	 f ƒ rš y+ |  j d |  j
 d |  j d |  j ƒ } Wq£ t k
 r– |  j ƒ  } q£ Xn	 |  j } | j |  j ƒ |  _ |  j rÛ t j |  j j ƒ  ƒ n  d  S(   NR   R   R   (   R   R   R   R   R   t   TextTestRunnerR   t   typet   typest	   ClassTypeR   R   R   t	   TypeErrort   runR>   t   resultR   R   t   wasSuccessful(   R   R   (    (    s#   /usr/lib/python2.7/unittest/main.pyR   Õ   s    	
			N(   R5   t
   __module__t   __doc__t   USAGE_FROM_MODULER%   R   R   R   R   R   R    t   defaultTestLoaderR3   R   R(   R   R6   t
   TestLoaderR1   R   (    (    (    s#   /usr/lib/python2.7/unittest/main.pyR   ?   s   			*	5(   R\   R   R   RU   R    R    R   t   signalsR   R3   t
   __unittestR"   R#   R$   t   USAGE_AS_MAINR]   t   objectR   t   main(    (    (    s#   /usr/lib/python2.7/unittest/main.pyt   <module>   s   ª