HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/_pytest/__pycache__/logging.cpython-310.pyc
o

%weR��@sVdZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl"m$Z$ddl"m%Z%ddl"m&Z&ddl"m'Z'ddl(m)Z)ddl*m+Z+dd l,m-Z-dd!l,m.Z.dd"l/m0Z0dd#l1m2Z2dd$l3m4Z4er�ej5eZ6dd%l7m8Z8nej5Z6d&Z9d'Z:e�;d(�Z<e2d)�Z=e2ee>eejf�Z?d*e>d+e>fd,d-�Z@Gd.d/�d/ejA�ZBGd0d1�d1eB�ZCGd2d3�d3ejD�ZEd4e$d5e>fd6d7�ZFd8e)d+dfd9d:�ZGed;ejHd<�ZIGd=d>�d>�ZJGd?d)�d)e6�ZKe!Gd@dA�dA��ZLe-dBe.d+eeLddffdCdD��ZMd4e$dEe>d+eeNfdFdG�ZOe&dHdI�d4e$d+dfdJdK��ZPGdLdM�dM�ZQGdNdO�dOejR�ZSGdPdQ�dQe6�ZTGdRdS�dSejU�ZVdS)Tz!Access and control log capturing.�N)�contextmanager)�nullcontext)�datetime)�	timedelta)�timezone)�StringIO)�	LogRecord)�Path)�AbstractSet)�Dict)�	Generator)�List)�Mapping)�Optional)�Tuple)�
TYPE_CHECKING)�TypeVar)�Union)�nodes)�TerminalWriter)�CaptureManager)�final)�
_strtobool)�Config)�create_terminal_writer)�hookimpl)�
UsageError)�Parser)�check_ispytest)�fixture)�FixtureRequest)�Session)�StashKey)�TerminalReporter)�Literalz<%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)sz%H:%M:%Sz
\x1b\[[\d;]+m�LogCaptureHandler�text�returncCst�d|�S)N�)�_ANSI_ESCAPE_SEQ�sub)r&�r+�H/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/logging.py�_remove_ansi_escape_sequences8sr-cs,eZdZdZddedef�fdd�
Z�ZS)�DatetimeFormatterz�A logging formatter which formats record with
    :func:`datetime.datetime.strftime` formatter instead of
    :func:`time.strftime` in case of microseconds in format string.
    N�recordr'csf|r,d|vr,|�|j�}tt|jd�|j�}t|dd�t|jd�|d��}|�	|�St
��||�S)Nz%f)�secondsr�i�)�microsecond�tzinfo)�	converter�createdrr�	tm_gmtoff�tm_zoner�round�msecs�strftime�super�
formatTime)�selfr/�datefmt�ct�tz�dt��	__class__r+r,r<Bs"
zDatetimeFormatter.formatTime�N)�__name__�
__module__�__qualname__�__doc__r�strr<�
__classcell__r+r+rBr,r.<s r.cs�eZdZUdZejdhejddhejdhejdhej	dhej
dheje�iZ
eeeefed<e�d�Zd	ed
df�fdd
�Zdeded
dfdd�Zdejd
ef�fdd�Z�ZS)�ColoredLevelFormatterzfA logging formatter which colorizes the %(levelname)..s part of the
    log format passed to __init__.�red�bold�yellow�green�purple�LOGLEVEL_COLOROPTSz$%\(levelname\)([+-.]?\d*(?:\.\d+)?s)�terminalwriterr'NcsRt�j|i|��||_|jj|_i|_|j��D]
\}}|j	|g|�R�qdSrD)
r;�__init__�_terminalwriter�_style�_fmt�
_original_fmt�_level_to_fmt_mappingrQ�items�add_color_level)r=rR�args�kwargs�level�
color_optsrBr+r,rS]s
�zColoredLevelFormatter.__init__r]r^cGsz|jdusJ�|j�|j�}|sdS|��}|dt�|�i}dd�|D�}|jj|fi|��}|j�||j�|j	|<dS)a�Add or update color opts for a log level.

        :param level:
            Log level to apply a style to, e.g. ``logging.INFO``.
        :param color_opts:
            ANSI escape sequence color options. Capitalized colors indicates
            background color, i.e. ``'green', 'Yellow', 'bold'`` will give bold
            green text on yellow background.

        .. warning::
            This is an experimental API.
        N�	levelnamecSsi|]}|d�qS)Tr+)�.0�namer+r+r,�
<dictcomp>}sz9ColoredLevelFormatter.add_color_level.<locals>.<dictcomp>)
rV�LEVELNAME_FMT_REGEX�search�group�logging�getLevelNamerT�markupr*rX)r=r]r^�levelname_fmt_match�
levelname_fmt�formatted_levelname�color_kwargs�colorized_formatted_levelnamer+r+r,rZfs���z%ColoredLevelFormatter.add_color_levelr/cs&|j�|j|j�}||j_t��|�SrD)rX�get�levelnorWrUrVr;�format)r=r/�fmtrBr+r,rp�szColoredLevelFormatter.format)rErFrGrHrf�CRITICAL�ERROR�WARNING�WARN�INFO�DEBUG�NOTSET�setrQr�intr
rI�__annotations__�re�compilercrrSrZrrprJr+r+rBr,rKNs

�
		 rKcspeZdZdZdedeeeedfddf�fdd�Ze	deeeedfdefd	d
��Z
dejdefdd
�Z
�ZS)�PercentStyleMultilinez�A logging style with special support for multiline messages.

    If the message of a record consists of multiple lines, this style
    formats the message as if each line were logged separately.
    rq�auto_indentNr'cst��|�|�|�|_dSrD)r;rS�_get_auto_indent�_auto_indent)r=rqrrBr+r,rS�szPercentStyleMultiline.__init__�auto_indent_optioncCs�|durdSt|t�r|rdSdSt|t�rt|�St|t�rCzt|�WSty-Ynwz
t|�r6WdSWdStyBYdSwdS)aDetermine the current auto indentation setting.

        Specify auto indent behavior (on/off/fixed) by passing in
        extra={"auto_indent": [value]} to the call to logging.log() or
        using a --log-auto-indent [value] command line or the
        log_auto_indent [value] config option.

        Default behavior is auto-indent off.

        Using the string "True" or "on" or the boolean True as the value
        turns auto indent on, using the string "False" or "off" or the
        boolean False or the int 0 turns it off, and specifying a
        positive integer fixes the indentation position to the value
        specified.

        Any other values for the option are invalid, and will silently be
        converted to the default.

        :param None|bool|int|str auto_indent_option:
            User specified option for indentation from command line, config
            or extra kwarg. Accepts int, bool or str. str option accepts the
            same range of values as boolean config options, as well as
            positive integers represented in str form.

        :returns:
            Indentation value, which can be
            -1 (automatically determine indentation) or
            0 (auto-indent turned off) or
            >0 (explicitly set indentation position).
        Nr���)�
isinstance�boolrzrI�
ValueErrorr)r�r+r+r,r��s.!



����z&PercentStyleMultiline._get_auto_indentr/cCs�d|jvrFt|d�r|�|j�}n|j}|rF|j��}|ji|j�d|di�}|dkr7t|��	|d�}n|}||d<dd|�
|�S|j|jS)N�
r�messager� )r��hasattrr�rr��
splitlinesrV�__dict__r-�find�join)r=r/r�lines�	formatted�indentationr+r+r,rp�s


�zPercentStyleMultiline.format)rErFrGrHrIrrzr�rS�staticmethodr�rfrrprJr+r+rBr,r~�s& 6r~�config�namescGs6|D]}|�|�}|dur|�|�}|r|SqdSrD)�	getoption�getini)r�r�ra�retr+r+r,�get_option_ini�s

��r��parsercs���d��d/��fdd�	}|dddddd	�|d
dtdd
�|ddtdd
��jddddd�|ddddd
�|ddddd
�|ddddd
�|ddddd
�|d d!dd"d
�|d#d$tdd
�|d%d&tdd
�|d'd(dd)d
��jd*d+gd,d-d.�dS)0z%Add options to control log capturing.rfNcs0�j|||d|d��j|fd|i|��dS)NzDefault value for ��default�type�help�dest)�addini�	addoption)�optionr�r�r�r\�rer�r+r,�add_option_ini�s�z(pytest_addoption.<locals>.add_option_iniz--log-level�	log_level�LEVELz�Level of messages to catch/display. Not set by default, so it depends on the root/parent log handler's effective level, where it is "WARNING" by default.)r�r��metavarr�z--log-format�
log_formatz%Log format used by the logging module)r�r�r�z--log-date-format�log_date_formatz*Log date format used by the logging module�log_cliFr�zAEnable log display during test run (also known as "live logging")r��--log-cli-level�
log_cli_levelzCLI logging levelz--log-cli-format�log_cli_formatz--log-cli-date-format�log_cli_date_formatz
--log-file�log_filez.Path to a file when logging will be written toz--log-file-level�log_file_levelzLog file logging levelz--log-file-format�log_file_formatz--log-file-date-format�log_file_date_formatz--log-auto-indent�log_auto_indentzfAuto-indent multiline messages passed to the logging module. Accepts true|on, false|off or an integer.z
--log-disable�append�logger_disablez7Disable a logger by name. Can be passed multiple times.)�actionr�r�r�)NN)�getgroup�DEFAULT_LOG_FORMAT�DEFAULT_LOG_DATE_FORMATr�r�)r�r�r+r�r,�pytest_addoption�s�
������������
�r��_HandlerType)�boundc@s@eZdZdZdZd
dedeeddfdd�Zd	d
�Z	dd�Z
dS)�
catching_logszCContext manager that prepares the whole logging machinery properly.)�handlerr]�
orig_levelNr�r]r'cCs||_||_dSrD)r�r])r=r�r]r+r+r,rSTs
zcatching_logs.__init__cCsXt��}|jdur|j�|j�|�|j�|jdur)|j|_|�t|j|j��|jSrD)rf�	getLoggerr]r��setLevel�
addHandlerr��min)r=�root_loggerr+r+r,�	__enter__Xs

zcatching_logs.__enter__cCs.t��}|jdur|�|j�|�|j�dSrD)rfr�r]r�r��
removeHandlerr�)r=r��value�	tracebackr�r+r+r,�__exit__bs
zcatching_logs.__exit__rD)rErFrGrH�	__slots__r�rrzrSr�r�r+r+r+r,r�Os
r�csbeZdZdZd�fdd�Zdejddf�fdd�Zdd	d
�Zddd�Z	dejddfd
d�Z
�ZS)r%z;A logging handler that stores log records and the log text.r'Ncst��t��g|_dS)zCreate a new log handler.N)r;rSr�records�r=rBr+r,rSls
zLogCaptureHandler.__init__r/cs|j�|�t��|�dS)z;Keep the log records in a list in addition to the log text.N)r�r�r;�emit�r=r/rBr+r,r�qszLogCaptureHandler.emitcCsg|_t�|_dSrD)r�r�streamr�r+r+r,�resetvszLogCaptureHandler.resetcCs|j��t�|_dSrD)r��clearrr�r�r+r+r,r�zs
zLogCaptureHandler.clearcCstjr�dSrD)rf�raiseExceptionsr�r+r+r,�handleError~s�zLogCaptureHandler.handleError�r'N)rErFrGrHrSrfrr�r�r�r�rJr+r+rBr,r%is

c	@s>eZdZdZdd�dejdeddfdd	�Zd&d
d�Ze	de
fdd
��Zdddee
jfdd�Ze	defdd��Ze	dee
jfdd��Ze	deeeeeffdd��Ze	deefdd��Zd&dd�Zdeeefde
jdefdd�Zd'deeefd eeddfd!d"�Ze	d'deeefd eeded#fd$d%��ZdS)(�LogCaptureFixturez-Provides access and control of log capturing.F��	_ispytest�itemr�r'NcCs$t|�||_d|_i|_d|_dSrD)r�_item�_initial_handler_level�_initial_logger_levels�_initial_disabled_logging_level)r=r�r�r+r+r,rS�s

zLogCaptureFixture.__init__cCsd|jdur|j�|j�|j��D]\}}t�|�}|�|�q|jdur0t�|j�d|_dSdS)z�Finalize the fixture.

        This restores the log levels and the disabled logging levels changed by :meth:`set_level`.
        N)	r�r�r�r�rYrfr�r��disable)r=�logger_namer]�loggerr+r+r,�	_finalize�s



�zLogCaptureFixture._finalizecCs|jjtS)z,Get the logging handler used by the fixture.)r��stash�caplog_handler_keyr�r+r+r,r��szLogCaptureFixture.handler�whenz$Literal['setup', 'call', 'teardown']cCs|jjt�|g�S)a5Get the logging records for one of the possible test phases.

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

        :returns: The list of captured records at the given stage.

        .. versionadded:: 3.4
        )r�r��caplog_records_keyrn�r=r�r+r+r,�get_records�s
zLogCaptureFixture.get_recordscCst|jj���S)zThe formatted log text.)r-r�r��getvaluer�r+r+r,r&�szLogCaptureFixture.textcCs|jjS)zThe list of log records.)r�r�r�r+r+r,r��szLogCaptureFixture.recordscC�dd�|jD�S)z�A list of a stripped down version of log records intended
        for use in assertion comparison.

        The format of the tuple is:

            (logger_name, log_level, message)
        cSsg|]}|j|j|��f�qSr+)raro�
getMessage�r`�rr+r+r,�
<listcomp>�sz3LogCaptureFixture.record_tuples.<locals>.<listcomp>�r�r�r+r+r,�
record_tuples�s	zLogCaptureFixture.record_tuplescCr�)a�A list of format-interpolated log messages.

        Unlike 'records', which contains the format string and parameters for
        interpolation, log messages in this list are all interpolated.

        Unlike 'text', which contains the output from the handler, log
        messages in this list are unadorned with levels, timestamps, etc,
        making exact comparisons more reliable.

        Note that traceback or stack info (from :func:`logging.exception` or
        the `exc_info` or `stack_info` arguments to the logging functions) is
        not included, as this is added by the formatter in the handler.

        .. versionadded:: 3.7
        cSsg|]}|���qSr+)r�r�r+r+r,r��sz.LogCaptureFixture.messages.<locals>.<listcomp>r�r�r+r+r,�messages�szLogCaptureFixture.messagescCs|j��dS)z8Reset the list of log records and the captured log text.N)r�r�r�r+r+r,r��szLogCaptureFixture.clearr]�
logger_objcCs^|jj}t|t�rt�|�}t|t�st�tj�|S|�|�s-t	|dtj�}t�|�|S)aPEnable the desired logging level if the global level was disabled via ``logging.disabled``.

        Only enables logging levels greater than or equal to the requested ``level``.

        Does nothing if the desired ``level`` wasn't disabled.

        :param level:
            The logger level caplog should capture.
            All logging is enabled if a non-standard logging level string is supplied.
            Valid level strings are in :data:`logging._nameToLevel`.
        :param logger_obj: The logger object to check.

        :return: The original disabled logging level.
        �
)
�managerr�r�rIrfrgrzrx�isEnabledFor�max)r=r]r��original_disable_level�
disable_levelr+r+r,�_force_enable_logging�s



�
z'LogCaptureFixture._force_enable_loggingr�cCsht�|�}|j�||j�|�|�|jdur|jj|_|j�|�|�||�}|j	dur2||_	dSdS)aSet the threshold level of a logger for the duration of a test.

        Logging messages which are less severe than this level will not be captured.

        .. 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.

        Will enable the requested logging level if it was disabled via :meth:`logging.disable`.

        :param level: The level.
        :param logger: The logger to update. If not given, the root logger.
        N)
rfr�r��
setdefaultr]r�r�r�r�r�)r=r]r�r��initial_disabled_logging_levelr+r+r,�	set_levels





�zLogCaptureFixture.set_level�NNNc	cs��t�|�}|j}|�|�|jj}|j�|�|�||�}zdVW|�|�|j�|�t�|�dS|�|�|j�|�t�|�w)auContext manager that sets the level for capturing of logs. After
        the end of the 'with' statement the level is restored to its original
        value.

        Will enable the requested logging level if it was disabled via :meth:`logging.disable`.

        :param level: The level.
        :param logger: The logger to update. If not given, the root logger.
        N)rfr�r]r�r�r�r�)r=r]r�r�r��handler_orig_levelr�r+r+r,�at_levels�




�zLogCaptureFixture.at_levelr�rD) rErFrGrHr�Noder�rSr��propertyr%r�r
rfrr�rIr&r�rrzr�r�r�r�Loggerr�rr�rrr�r+r+r+r,r��sJ
�
�


��
�$"�
���r��requestccs"�t|jdd�}|V|��dS)a�Access and control log capturing.

    Captured logs are available through the following properties/methods::

    * caplog.messages        -> list of format-interpolated log messages
    * caplog.text            -> string containing formatted log output
    * caplog.records         -> list of logging.LogRecord instances
    * caplog.record_tuples   -> list of (logger_name, level, message) tuples
    * caplog.clear()         -> clear captured records and formatted log output string
    Tr�N)r��noder�)r�resultr+r+r,�caplog9s�r�
setting_namesc
Gs�|D]}|�|�}|dur|�|�}|rnqdSt|t�r"|��}z	ttt||��WSty@}z	t	d�
||��|�d}~ww)Nzo'{}' is not recognized as a logging level name for '{}'. Please consider passing the logging level num instead.)r�r�r�rI�upperrz�getattrrfr�rrp)r�r�setting_namer��er+r+r,�get_log_level_for_settingJs*

�
����r	T)�trylastcCs|j�t|�d�dS)Nzlogging-plugin)�
pluginmanager�register�
LoggingPlugin)r�r+r+r,�pytest_configurebsrc@s�eZdZdZdeddfdd�Zdeeddfdd	�Zd
d�Z	deddfd
d�Z
dd�Zeddd�de
dfdd��Zeddd�de
dfdd��Zedd�dede
dfdd��Zed0dd��Zed0dd��Zd ejd!ede
dfd"d#�Zedd�d ejde
dfd$d%��Zedd�d ejde
dfd&d'��Zedd�d ejde
dfd(d)��Zed0d*d+��Zeddd�de
dfd,d-��Zed0d.d/��ZdS)1r
zGAttaches to the logging module and captures log messages for each test.r�r'Nc
Cs�||_|�t|d�t|d�t|d��|_t|d�|_t�|_|j�|j�t�|_	|j	�|j�t|d�|_
t|d�p=tj}|tjkrXtj
�tj
�|��}tj
�|�sXt�|�t|ddd	�|_t|d
d�}t|dd�}t||d�}|j�|�t|d
d�|_|��r�|j�d�}|dus�J�|j�d�}t||�|_nt�|_|�t|dd�t|dd�t|d��}	|j�|	�|j|jjd�dS)z�Create 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.
        r�r�r�r�r�r��w�UTF-8��mode�encodingr�r�)r>r��terminalreporterN�capturemanagerr�r�)�loggers_to_disable)�_config�_create_formatterr��	formatterr	r�r%�caplog_handler�setFormatter�report_handlerr��os�devnull�path�dirname�abspath�isdir�makedirs�_FileHandler�log_file_handlerr.r��_log_cli_enabledr�
get_plugin�_LiveLoggingStreamHandler�log_cli_handler�_LiveLoggingNullHandler�_disable_loggersr�r�)
r=r�r��	directoryr�r��log_file_formatter�terminal_reporter�capture_manager�log_cli_formatterr+r+r,rSjsV�

����

�zLoggingPlugin.__init__rcCs&|sdS|D]
}t�|�}d|_qdS)NT)rfr��disabled)r=rrar�r+r+r,r+�s
�zLoggingPlugin._disable_loggerscCsXt|jjdd�}|dkrtj�|�rtt|j�||�}nt||�}t|j	j
|d�|_	|S)N�color�no)r)rrr�rKrcrdrr.r~rUrV)r=r�r�rr2rr+r+r,r�s��
�zLoggingPlugin._create_formatter�fnamecCsdt|�}|��s|jj|}|j��s|jjddd�|jddd�}|j�	|�}|r0|�
�dSdS)z�Set the filename parameter for Logging.FileHandler().

        Creates parent directory if it does not exist.

        .. warning::
            This is an experimental API.
        T)�exist_ok�parentsrrrN)r	�is_absoluter�rootpath�parent�exists�mkdir�openr%�	setStream�close)r=r4�fpathr��
old_streamr+r+r,�set_log_path�s
�zLoggingPlugin.set_log_pathcCsB|j�d�dup
|j�d�}|sdS|jj�d�}|durdSdS)z'Return whether live logging is enabled.r�Nr�FrT)rr�r�rr')r=�enabledr.r+r+r,r&�s��
�zLoggingPlugin._log_cli_enabledT)�hookwrapper�tryfirstr�c	c��|j�d�t|j|jd��,t|j|jd��dVWd�n1s&wYWd�dSWd�dS1s>wYdS)N�sessionstart�r]�r)�set_whenr�r�r%r�r�r+r+r,�pytest_sessionstart�����"�z!LoggingPlugin.pytest_sessionstartc	crE)N�
collectionrGrHr�r+r+r,�pytest_collection�rKzLoggingPlugin.pytest_collection)rC�sessionc	cs��|jjjrdVdS|��r|j�d�dkrd|jj_t|j|j	d��,t|j
|jd��dVWd�n1s;wYWd�dSWd�dS1sSwYdS)N�verbose�rG)r�r��collectonlyr&rr�rOr�r)r�r%r�)r=rNr+r+r,�pytest_runtestloop�s�

��"�z LoggingPlugin.pytest_runtestloopcCs|j��|j�d�dS)N�start)r)r�rIr�r+r+r,�pytest_runtest_logstarts
z%LoggingPlugin.pytest_runtest_logstartcC�|j�d�dS)N�	logreport�r)rIr�r+r+r,�pytest_runtest_logreport
�z&LoggingPlugin.pytest_runtest_logreportr�r�c	cs��t|j|jd��O}t|j|jd��.}|��|��|j|jt|<||jt<dV|j	�
���}|�|d|�Wd�n1sCwYWd�dSWd�dS1s[wYdS)z:Implement the internals of the pytest_runtest_xxx() hooks.rGN�log)
r�rr�rr�r�r�r�r�r�r��strip�add_report_section)r=r�r�rrrZr+r+r,�_runtest_fors&����
P�zLoggingPlugin._runtest_forccs2�|j�d�i}||jt<|�|d�EdHdS)N�setup)r)rIr�r�r])r=r��emptyr+r+r,�pytest_runtest_setup!s
�
z"LoggingPlugin.pytest_runtest_setupccs$�|j�d�|�|d�EdHdS)N�call)r)rIr]�r=r�r+r+r,�pytest_runtest_call)s�z!LoggingPlugin.pytest_runtest_callccs4�|j�d�|�|d�EdH|jt=|jt=dS)N�teardown)r)rIr]r�r�r�rbr+r+r,�pytest_runtest_teardown/s
�z%LoggingPlugin.pytest_runtest_teardowncCrU)N�finishrWr�r+r+r,�pytest_runtest_logfinish7rYz&LoggingPlugin.pytest_runtest_logfinishc	crE)N�
sessionfinishrGrHr�r+r+r,�pytest_sessionfinish;rKz"LoggingPlugin.pytest_sessionfinishcCs|j��dSrD)r%r>r�r+r+r,�pytest_unconfigureCsz LoggingPlugin.pytest_unconfigurer�)rErFrGrHrrSr
rIr+rrAr&rrrJrMr!rRrTrXr�Itemr]r`rcrergrirjr+r+r+r,r
gs<>



r
c@s$eZdZdZdejddfdd�ZdS)r$z)A logging FileHandler with pytest tweaks.r/r'NcC�dSrDr+r�r+r+r,r�M�z_FileHandler.handleError)rErFrGrHrfrr�r+r+r+r,r$Jsr$cs�eZdZUdZdZeed<dedeeddf�fdd�Z	dd	d
�Z
deeddfdd
�Zde
jddf�fdd�Zde
jddfdd�Z�ZS)r(aA logging 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.
    Nr�r.r/r'cs0t�j|d�||_|��|�d�d|_dS)N)r�F)r;rSr/r�rI�_test_outcome_written)r=r.r/rBr+r,rS_s


z"_LiveLoggingStreamHandler.__init__cCs
d|_dS)zBReset the handler; should be called before the start of each test.FN)�_first_record_emittedr�r+r+r,r�js
z_LiveLoggingStreamHandler.resetr�cCs"||_d|_|dkrd|_dSdS)z7Prepare for the given test phase (setup/call/teardown).FrSN)�_when�_section_name_shownrnr�r+r+r,rIns

�z"_LiveLoggingStreamHandler.set_whenr/cs�|jr|j��nt�}|�B|js|j�d�d|_n|jdvr,|js,d|_|j�d�|jsA|jrA|jj	d|jddd�d|_t
��|�Wd�dS1sRwYdS)Nr�T)rdrfz	live log �-)�seprM)r/�global_and_fixture_disabledrror��writerprnrq�sectionr;r�)r=r/�ctx_managerrBr+r,r�us"��
"�z_LiveLoggingStreamHandler.emitcCrlrDr+r�r+r+r,r��rmz%_LiveLoggingStreamHandler.handleErrorr�)rErFrGrHr�r#r{rrrSr�rIrIrfrr�r�rJr+r+rBr,r(Rs

���
r(c@s@eZdZdZddd�Zdeddfdd�Zd	ejddfd
d�Z	dS)
r*z5A logging handler used when live logging is disabled.r'NcCrlrDr+r�r+r+r,r���z_LiveLoggingNullHandler.resetr�cCrlrDr+r�r+r+r,rI�rxz _LiveLoggingNullHandler.set_whenr/cCrlrDr+r�r+r+r,r��rmz#_LiveLoggingNullHandler.handleErrorr�)
rErFrGrHr�rIrIrfrr�r+r+r+r,r*�s

r*)WrH�iorfrr|�
contextlibrrrrrrr�pathlibr	�typingr
rrr
rrrrrr�_pytestr�_pytest._ior�_pytest.capturer�_pytest.compatr�_pytest.configrrrrr�_pytest.config.argparsingr�_pytest.deprecatedr�_pytest.fixturesrr �_pytest.mainr!�
_pytest.stashr"�_pytest.terminalr#�
StreamHandler�logging_StreamHandler�typing_extensionsr$r�r�r}r)r�rIr�r-�	Formatterr.rK�PercentStyler~r�r��Handlerr�r�r%r�rrzr	rr
�FileHandlerr$r(�NullHandlerr*r+r+r+r,�<module>s�


=Z	]2d;