ó
J9Qc           @   s<   d  Z  d d l Z d d l m Z d e f d     YZ d S(   sĘ   
This plugin provides ``--pdb`` and ``--pdb-failures`` options. The ``--pdb``
option will drop the test runner into pdb when it encounters an error. To
drop into pdb on failure, use ``--pdb-failures``.
i˙˙˙˙N(   t   Plugint   Pdbc           B   sM   e  Z d  Z e Z e Z d Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   s   
    Provides --pdb and --pdb-failures options that cause the test runner to
    drop into pdb if it encounters an error or failure, respectively.
    i   c      
   C   sf   | j  d d d d d d | j d t  d d	 | j  d
 d d d d d | j d t  d d d S(   s&   Register commandline options.
        s   --pdbt   actiont
   store_truet   destt   debugErrorst   defaultt   NOSE_PDBt   helps   Drop into debugger on errorss   --pdb-failurest   debugFailurest   NOSE_PDB_FAILURESs   Drop into debugger on failuresN(   t
   add_optiont   gett   False(   t   selft   parsert   env(    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyt   options   s    c         C   s:   | |  _  | j p | j |  _ | j |  _ | j |  _ d S(   s<   Configure which kinds of exceptions trigger plugin.
        N(   t   confR   R	   t   enabledt   enabled_for_errorst   enabled_for_failures(   R   R   R   (    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyt	   configure    s    	c         C   s   |  j  s d S|  j |  d S(   s1   Enter pdb if configured to debug errors.
        N(   R   t   debug(   R   t   testt   err(    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyt   addError(   s    	c         C   s   |  j  s d S|  j |  d S(   s3   Enter pdb if configured to debug failures.
        N(   R   R   (   R   R   R   (    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyt
   addFailure/   s    	c         C   sR   d d  l  } | \ } } } | j } | j | _ z t j |  Wd  | | _ Xd  S(   Ni˙˙˙˙(   t   syst   stdoutt
   __stdout__t   pdbt   post_mortem(   R   R   R   t   ect   evt   tbR   (    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyR   6   s    	(   t   __name__t
   __module__t   __doc__R   R   R   t   scoreR   R   R   R   R   (    (    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyR   
   s   				(   R&   R   t   nose.plugins.baseR    R   (    (    (    s6   /sys/lib/python2.7/site-packages/nose/plugins/debug.pyt   <module>   s   