B
    ~RS                 @   s,   d Z ddlZddlmZ G dd deZdS )z
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``.
    N)Pluginc               @   sD   e Zd ZdZdZdZdZdd Zdd Zdd	 Z	d
d Z
dd ZdS )Pdbz
    Provides --pdb and --pdb-failures options that cause the test runner to
    drop into pdb if it encounters an error or failure, respectively.
    F   c             C   sX   |j ddd|dddd |j ddd	|d
ddd |j ddd|dddd dS )z&Register commandline options.
        z--pdb
store_true	debugBothZNOSE_PDBFz(Drop into debugger on failures or errors)actiondestdefaulthelpz--pdb-failuresdebugFailuresZNOSE_PDB_FAILURESzDrop into debugger on failuresz--pdb-errorsdebugErrorsZNOSE_PDB_ERRORSzDrop into debugger on errorsN)Z
add_optionget)selfparserenv r   1lib/python3.7/site-packages/nose/plugins/debug.pyoptions   s    


zPdb.optionsc             C   s4   || _ |jp|j| _|jp|j| _| jp,| j| _dS )z<Configure which kinds of exceptions trigger plugin.
        N)confr   r   enabled_for_errorsr   enabled_for_failuresZenabled)r   r   r   r   r   r   	configure%   s    zPdb.configurec             C   s   | j s
dS | | dS )z1Enter pdb if configured to debug errors.
        N)r   debug)r   testerrr   r   r   addError-   s    zPdb.addErrorc             C   s   | j s
dS | | dS )z3Enter pdb if configured to debug failures.
        N)r   r   )r   r   r   r   r   r   
addFailure4   s    zPdb.addFailurec             C   s<   dd l }|\}}}|j}|j|_zt| W d ||_X d S )Nr   )sysstdout
__stdout__pdbZpost_mortem)r   r   r   ZecZevtbr   r   r   r   r   ;   s    
z	Pdb.debugN)__name__
__module____qualname____doc__r   r   Zscorer   r   r   r   r   r   r   r   r   r   
   s   r   )r%   r    Znose.plugins.baser   r   r   r   r   r   <module>   s   