Your IP : 216.73.216.213
B
R�Xd � @ sj d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ G dd� dej �Z
G dd� de
�Zd d
� ZdS )� )�defaultdictN)�compare)�wrapc @ s� e Zd ZdZe� ZdZdZd!dd�Ze d d
� �Z
dd� Zd
d� Zdd� Z
dd� Ze dd� �Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � ZdS )"�
LogCapturea|
These are used to capture entries logged to the Python logging
framework and make assertions about what was logged.
:param names: A string (or tuple of strings) containing the dotted name(s)
of loggers to capture. By default, the root logger is
captured.
:param install: If `True`, the :class:`LogCapture` will be
installed as part of its instantiation.
:param propagate: If specified, any captured loggers will have their
`propagate` attribute set to the supplied value. This can
be used to prevent propagation from a child logger to a
parent logger that has configured handlers.
:param attributes:
The sequence of attribute names to return for each record or a callable
that extracts a row from a record..
If a sequence of attribute names, those attributes will be taken from the
:class:`~logging.LogRecord`. If an attribute is callable, the value
used will be the result of calling it. If an attribute is missing,
``None`` will be used in its place.
If a callable, it will be called with the :class:`~logging.LogRecord`
and the value returned will be used as the row..
:param recursive_check:
If ``True``, log messages will be compared recursively by
:meth:`LogCapture.check`.
FNT� ��nameZ levelnameZ
getMessagec C s\ t j�| � t|t�s|f}|| _|| _|| _|| _|| _ t
t�| _| �
� |rX| �� d S )N)�logging�Handler�__init__�
isinstance�tuple�names�level� propagate�
attributes�recursive_checkr �dict�old�clear�install)�selfr r r r r r � r �H/opt/alt/python37/lib/python3.7/site-packages/testfixtures/logcapture.pyr 5 s
zLogCapture.__init__c C s* | j r&t�dd�dd� | j D �� � d S )NzFLogCapture instances not uninstalled by shutdown, loggers captured:
%s�
c s s | ]}t |j�V qd S )N)�strr )�.0�ir r r � <genexpr>K s z$LogCapture.atexit.<locals>.<genexpr>)� instances�warnings�warn�join)�clsr r r �atexitE s zLogCapture.atexitc C s
g | _ dS )z*Clear any entries that have been captured.N)�records)r r r r r N s zLogCapture.clearc C s | j �|� d S )N)r% �append)r �recordr r r �emitR s zLogCapture.emitc C s� x�| j D ]z}t�|�}|j| jd |<