%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/prof.cpython-37.pyc

B

�fP��@s�dZyddlZddlmZWnek
r8d\ZZYnXddlZddlZddlZddlZddlm	Z	ddl
mZe�d�Z
Gdd	�d	e	�ZdS)
a/This plugin will run tests using the hotshot profiler, which is part
of the standard library. To turn it on, use the ``--with-profile`` option
or set the NOSE_WITH_PROFILE environment variable. Profiler output can be
controlled with the ``--profile-sort`` and ``--profile-restrict`` options,
and the profiler output file may be changed with ``--profile-stats-file``.

See the `hotshot documentation`_ in the standard library documentation for
more details on the various output options.

.. _hotshot documentation: http://docs.python.org/library/hotshot.html
�N)�stats)NN)�Plugin)�tolistznose.pluginsc@s`eZdZdZdZdZdd�Zdd�Zee�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�ProfilezC
    Use this plugin to run tests using the hotshot profiler. 
    NFcCst|��sdSt�|||�|jddd|�dd�ddd	�|jd
ddd|�d
�dd�|jdddd|�d�dd�dS)z&Register commandline options.
        Nz--profile-sortZstore�profile_sortZNOSE_PROFILE_SORTZ
cumulativeZSORTz"Set sort order for profiler output)�action�dest�default�metavar�helpz--profile-stats-file�profile_stats_file�FILEZNOSE_PROFILE_STATS_FILEz;Profiler stats file; default is a new temp file on each run)rrr
r	rz--profile-restrict�append�profile_restrictZRESTRICTZNOSE_PROFILE_RESTRICTz?Restrict profiler output. See help for pstats.Stats for details)�	availabler�optionsZ
add_option�get)�self�parser�env�r�B/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/prof.pyr!s"

zProfile.optionscCstdk	S)N)�hotshot)�clsrrrr8szProfile.availablecCs&|��sdS|��t�|j�|_dS)z5Create profile stats file and load profiler.
        N)r�
_create_pfilerr�pfile�prof)rrrr�begin<sz
Profile.begincCsf|��sd|_dSt�|||�||_|jr<|j|_d|_nd|_d|_d|_|j	|_
t|j�|_
dS)zConfigure plugin.
        FNT)rZenabledr�	configure�confrr�clean_stats_file�filenor�sortrr�restrict)rrrrrrrDszProfile.configurecs2���sdSt�d|��j|f�fdd�	}|S)z6Wrap entire test run in :func:`prof.runcall`.
        Nzpreparing test %scs���|�||�dS)N)rZruncall)�resultr�test)rrr�run_and_profile\sz,Profile.prepareTest.<locals>.run_and_profile)r�log�debugr)rr%r&r)rr�prepareTestVs
zProfile.prepareTestcCs�t�d�|j��t�|j�}|�|j�t	|d�}|rH|j
}||_
ntj}|t_z.|j
rxt�d|j
�|j|j
�n|��Wd|r�||_
n|t_XdS)z Output profiler report.
        zprinting profiler report�streamz"setting profiler restriction to %sN)r'r(r�closer�loadrZ
sort_statsr"�hasattrr*�sys�stdoutr#Zprint_stats)rr*Z
prof_statsZ	compat_25Ztmprrr�reportas$


zProfile.reportcCs�|��sdSy|j��Wntk
r.YnX|jr�|jrbyt�|j�Wntk
r`YnXyt�|j	�Wntk
r�YnXdS)z5Clean up stats file, if configured to do so.
        N)
rrr+�AttributeErrorr r!�os�OSError�unlinkr)rr$rrr�finalizes"zProfile.finalizecCs |jst��\|_|_d|_dS)NT)r�tempfileZmkstempr!r )rrrrr�szProfile._create_pfile)�__name__�
__module__�__qualname__�__doc__rr rr�classmethodrrr)r0r5rrrrrrsr)r:rr�ImportErrorZloggingr2r.r6Znose.plugins.baserZ	nose.utilrZ	getLoggerr'rrrrr�<module>s


Zerion Mini Shell 1.0