GhostManSec
Server: Apache
System: Linux s323.xrea.com 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: moonarc (17751)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/_pytest/logging.pyc
�
��abc@`sedZddlmZmZmZddlZddlmZmZddl	Z	ddl
Z
ddlmZddl
Z
ddlZdZdZdejfd	��YZd
�Zd�Zeddd��Zd
ejfd��YZdefd��YZe
jd��Zd�Zd�Zed��Zdefd��YZ dejfd��YZ!dS(s# Access and control log capturing. i(tabsolute_importtdivisiontprint_functionN(tclosingtcontextmanager(tcreate_terminal_writers7%(filename)-25s %(lineno)4d %(levelname)-8s %(message)ss%H:%M:%StColoredLevelFormattercB`s�eZdZidhej6ddhej6dhej6dhej6dhej6dhej	6e
�ej6Ze
jd�Zd�Zd�ZRS(	sQ
    Colorize the %(levelname)..s part of the log format passed to __init__.
    tredtboldtyellowtgreentpurples%\(levelname\)([+-]?\d*s)cO`s�tt|�j||�tjr1|j|_n|jj|_i|_|j	j
|j�}|shdS|j�}xx|jj
�D]g\}}|itj|�d6}d�|D�}	|j||	�}
|j	j|
|j�|j|<q�WdS(Nt	levelnamecS`si|]}t|�qS((tTrue(t.0tname((s3/usr/lib/python2.7/site-packages/_pytest/logging.pys
<dictcomp>5s	(tsuperRt__init__tsixtPY2t_fmtt
_original_fmtt_stylet_level_to_fmt_mappingtLEVELNAME_FMT_REGEXtsearchtgrouptLOGLEVEL_COLOROPTStitemstloggingtgetLevelNametmarkuptsub(tselftterminalwritertargstkwargstlevelname_fmt_matcht
levelname_fmttlevelt
color_optstformatted_levelnametcolor_kwargstcolorized_formatted_levelname((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR"s&
			cC`sR|jj|j|j�}tjr0||_n||j_tt	|�j
|�S(N(RtgettlevelnoRRRRRRRtformat(R!trecordtfmt((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR.<s		(t__name__t
__module__t__doc__RtCRITICALtERRORtWARNINGtWARNtINFOtDEBUGtsettNOTSETRtretcompileRRR.(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRs




	cG`sLxE|D]=}|j|�}|dkr:|j|�}n|r|SqWdS(N(t	getoptiontNonetgetini(tconfigtnamesRtret((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytget_option_iniFs
c`s��jd��d*d*��fd�}|ddddddtd	td
ddd
�|dddd	d*dd�|dddd	tdd�|dddd	tdd��jdd	td
ddd�|dddd	d*dd�|dddd	d*dd�|dddd	d*dd�|d dd!d	d*dd"�|d#dd$d	d*dd%�|d&dd'd	tdd�|d(dd)d	tdd�d*S(+s%Add options to control log capturing.Rc	`s=�j|d|d|dd|��j|d||�dS(Ntdefaultttypethelpsdefault value for tdest(taddinit	addoption(toptionRHRERFR$(Rtparser(s3/usr/lib/python2.7/site-packages/_pytest/logging.pytadd_option_iniSss--no-print-logsRHt	log_printtactiontstore_consttconstRERFtboolRGs-disable printing caught logs on failed tests.s--log-levelt	log_levels(logging level used by the logging modules--log-formatt
log_formats)log format as used by the logging module.s--log-date-formattlog_date_formats.log date format as used by the logging module.tlog_clisBenable log display during test run (also known as "live logging").s--log-cli-levelt
log_cli_levelscli logging level.s--log-cli-formattlog_cli_formats--log-cli-date-formattlog_cli_date_formats
--log-filetlog_files/path to a file when logging will be written to.s--log-file-leveltlog_file_levelslog file logging level.s--log-file-formattlog_file_formats--log-file-date-formattlog_file_date_formatN(tgetgroupR?tFalseR
tDEFAULT_LOG_FORMATtDEFAULT_LOG_DATE_FORMATRI(RLRM((RRLs3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_addoptionOsdcc`s�tj�}|dk	r(|j|�n|dk	rD|j|�n||jk}|ri|j|�n|dk	r�|j}|j|�nz	|VWd|dk	r�|j|�n|r�|j|�nXdS(sCContext manager that prepares the whole logging machinery properly.N(	Rt	getLoggerR?tsetFormattertsetLevelthandlerst
addHandlerR't
removeHandler(thandlert	formatterR'troot_loggertadd_new_handlert
orig_level((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt
catching_logs�s"		tLogCaptureHandlercB`s eZdZd�Zd�ZRS(s;A logging handler that stores log records and the log text.cC`s)tjj|tjj��g|_dS(sCreates a new log handler.N(Rt
StreamHandlerRtpytiotTextIOtrecords(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR�scC`s'|jj|�tjj||�dS(s;Keep the log records in a list in addition to the log text.N(RttappendRRptemit(R!R/((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRv�s(R1R2R3RRv(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRo�s	tLogCaptureFixturecB`s�eZdZd�Zd�Zed��Zd�Zed��Zed��Z	ed��Z
d�Zdd	�Z
edd
��ZRS(s-Provides access and control of log capturing.cC`s||_i|_dS(sCreates a new funcarg.N(t_itemt_initial_log_levels(R!titem((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR�s	cC`s@x9|jj�D](\}}tj|�}|j|�qWdS(scFinalizes the fixture.

        This restores the log levels changed by :meth:`set_level`.
        N(RyRRRcRe(R!tlogger_nameR'tlogger((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt	_finalize�scC`s
|jjS(N(Rxtcatch_log_handler(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRi�scC`s*|jjj|�}|r"|jSgSdS(s\
        Get the logging records for one of the possible test phases.

        :param str when:
            Which test phase to obtain the records from. Valid values are: "setup", "call" and "teardown".

        :rtype: List[logging.LogRecord]
        :return: the list of captured records at the given stage

        .. versionadded:: 3.4
        N(Rxtcatch_log_handlersR,Rt(R!twhenRi((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytget_records�scC`s|jjj�S(sReturns the log text.(Ritstreamtgetvalue(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyttext�scC`s
|jjS(s Returns the list of log records.(RiRt(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRt�scC`s/g|jD]!}|j|j|j�f^q
S(s�Returns a list of a striped down version of log records intended
        for use in assertion comparison.

        The format of the tuple is:

            (logger_name, log_level, message)
        (RtRR-t
getMessage(R!tr((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt
record_tuples�s	cC`sg|j_dS(sReset the list of log records.N(RiRt(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytclear�scC`s<|}tj|�}|jj||j�|j|�dS(s�Sets the level for capturing of logs. The level will be restored to its previous value at the end of
        the test.

        :param int level: the logger to level.
        :param str logger: the logger to update the level. If not given, the root logger level is updated.

        .. versionchanged:: 3.4
            The levels of the loggers changed by this function will be restored to their initial values at the
            end of the test.
        N(RRcRyt
setdefaultR'Re(R!R'R|R{((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt	set_level�scc`sCtj|�}|j}|j|�z	dVWd|j|�XdS(s9Context manager that sets the level for capturing of logs. After the end of the 'with' statement the
        level is restored to its original value.

        :param int level: the logger to level.
        :param str logger: the logger to update the level. If not given, the root logger level is updated.
        N(RRcR'Re(R!R'R|Rm((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytat_levels	
	N(R1R2R3RR}tpropertyRiR�R�RtR�R�R?R�RR�(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRw�s		
		cc`s"t|j�}|V|j�dS(s@Access and control log capturing.

    Captured logs are available through the following methods::

    * caplog.text()          -> string containing formatted log output
    * caplog.records()       -> list of logging.LogRecord instances
    * caplog.record_tuples() -> list of (logger_name, level, message) tuples
    N(RwtnodeR}(trequesttresult((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytcaplogs
cG`s�xI|D]=}|j|�}|dkr:|j|�}n|rPqqWdSt|tj�rm|j�}nyttt	||��SWn,t
k
r�tjdj
||���nXdS(s Return the actual logging level.Nsq'{0}' is not recognized as a logging level name for '{1}'. Please consider passing the logging level num instead.(R>R?R@t
isinstanceRtstring_typestuppertinttgetattrRt
ValueErrortpytestt
UsageErrorR.(RAt
setting_namestsetting_nameRS((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytget_actual_log_level&s 

cC`s|jjt|�d�dS(Nslogging-plugin(t
pluginmanagertregistert
LoggingPlugin(RA((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_configure@scc`s	dVdS(N((((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt_dummy_context_managerDsR�cB`s�eZdZd�Zed��Zejde�d��Z	ejde�d��Z
ejde�d��Zd�Zejde�d��Z
d	�ZRS(
sLAttaches to the logging module and captures log messages for each test.
    cC`sG||_|jjd�r[|jd�r[|jjjd�dksLt�d|j_nt	|d�|_
tjt	|d�t	|d��|_
t|d�|_t	|d	�}|r1t|d
�|_t	|dd�}t	|dd�}tj|d
d�|_tj|d|�}|jj|�n	d|_d|_dS(s�Creates a new plugin to capture log messages.

        The formatter can be safely shared across all handlers so
        create a single one for the entire test session here.
        RVtverbosetterminalreporteriRNRTRURSRZR[R\R]tmodetwtdatefmtN(t_configR@R>R�t
get_pluginR?tAssertionErrorRKR�RDt
print_logsRt	FormatterRjR�RSR[tFileHandlertlog_file_handlerRdtlog_cli_handler(R!RARZR\R]tlog_file_formatter((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRMs$	"!	c	c`s�tt�d|jd|j���}|jr@|jj|�nt|d�s[i|_n||j|<||_z	dVWd|`|dkr�|`nX|j	r�|j
j�j�}|j
|d|�nWdQXdS(s6Implements the internals of pytest_runtest_xxx() hook.RjR'RNtteardowntlog(RnRoRjRSR�tset_whenthasattrRR~R�R�R�tstriptadd_report_section(R!RzR�tlog_handlerR�((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt_runtest_forps 	
		
	thookwrappercc`s"|j|d��
dVWdQXdS(Ntsetup(R�(R!Rz((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_runtest_setup�scc`s"|j|d��
dVWdQXdS(Ntcall(R�(R!Rz((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_runtest_call�scc`s"|j|d��
dVWdQXdS(NR�(R�(R!Rz((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_runtest_teardown�scC`s|jr|jj�ndS(N(R�treset(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_runtest_logstart�s	c
c`so|j�|j�V|jdk	r`t|j��)t|jd|j��
dVWdQXWdQXndVWdQXdS(sRuns all collected test items.R'N(t_setup_cli_loggingtlive_logs_contextR�R?RRnR[(R!tsession((s3/usr/lib/python2.7/site-packages/_pytest/logging.pytpytest_runtestloop�s


cC`s*|jjjd�}|jjd�r|dk	r|jjjd�}t||�}t|jdd�}t|jdd�}|jjjdkr�t	j
j|�r�t	t|j�|d	|�}nt
j|d	|�}t|jd
d�}||_t|d|d
|�|_nt�|_dS(s�Sets up the handler and logger for the Live Logs feature, if enabled.

        This must be done right before starting the loop so we can access the terminal reporter plugin.
        R�RVtcapturemanagerRXRTRYRUtnoR�RWRSRjR'N(R�R�R�R@R?t_LiveLoggingStreamHandlerRDRKtcolorRRRRRR�R�R�RnR�R�(R!tterminal_reportertcapture_managerR�RXRYtlog_cli_formatterRW((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR��s'	(R1R2R3RRR�R�thookimplR
R�R�R�R�R�R�(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR�Is	#	
R�cB`s2eZdZd�Zd�Zd�Zd�ZRS(s
    Custom StreamHandler used by the live logging feature: it will write a newline before the first log message
    in each test.

    During live logging we must also explicitly disable stdout/stderr capturing otherwise it will get captured
    and won't appear in the terminal.
    cC`s:tjj|d|�||_|j�|jd�dS(s�
        :param _pytest.terminal.TerminalReporter terminal_reporter:
        :param _pytest.capture.CaptureManager capture_manager:
        R�N(RRpRR�R�R�R?(R!R�R�((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR�s	
cC`s
t|_dS(sAReset the handler; should be called before the start of each testN(R_t_first_record_emitted(R!((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR��scC`s||_t|_dS(s7Prepares for the given test phase (setup/call/teardown)N(t_whenR_t_section_name_shown(R!R�((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR��s	cC`s�|jdk	r|jj�nz�|js;|jdkrW|jjd�t|_n|jr�|jr�|jj	d|jdddt�t|_nt
jj||�Wd|jdk	r�|jj
�nXdS(NR�s
s	live log tsept-R(R�R?tsuspend_global_captureR�R�R�twriteR
R�tsectionRRpRvtresume_global_capture(R!R/((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyRv�s#(R1R2R3RR�R�Rv(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyR��s
	
		("R3t
__future__RRRRt
contextlibRRR<Rt_pytest.configRR�RqR`RaR�RRDRbR?RnRpRotobjectRwtfixtureR�R�R�R�R�R�(((s3/usr/lib/python2.7/site-packages/_pytest/logging.pyt<module>s.4			;c		u