a
    ñ»js  ã                   @   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)Ú
add_optionÚget)ÚselfÚparserÚenv© r   ú8E:\soccer\ml_env\Lib\site-packages\nose/plugins/debug.pyÚoptions   s    
ý
ý
ýzPdb.optionsc                 C   s4   || _ |jp|j| _|jp|j| _| jp,| j| _dS )z3Configure which kinds of exceptions trigger plugin.N)Úconfr   r   Úenabled_for_errorsr   Úenabled_for_failuresÚenabled)r   r   r   r   r   r   Ú	configure   s    zPdb.configurec                 C   s   | j s
dS |  |¡ dS )z(Enter 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 )z*Enter pdb if configured to debug failures.N)r   r   r   r   r   r   Ú
addFailure+   s    zPdb.addFailurec                 C   sB   dd l }|\}}}|j}|j|_zt |¡ W ||_n||_0 d S )Nr   )ÚsysÚstdoutÚ
__stdout__ÚpdbZpost_mortem)r   r   r    ÚecZevÚtbr!   r   r   r   r   1   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   