관리-도구
편집 파일: _log.cpython-39.opt-2.pyc
a R�f� � @ sR d dl Z d dlZddlmZ e�dddg�ZG dd� de j�ZG d d � d e�ZdS )� N� )�_BaseTestCaseContext�_LoggingWatcher�records�outputc @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�_CapturingHandlerc C s t j�| � tg g �| _d S �N)�logging�Handler�__init__r �watcher��self� r �2/opt/alt/python39/lib64/python3.9/unittest/_log.pyr s z_CapturingHandler.__init__c C s d S r r r r r r �flush s z_CapturingHandler.flushc C s* | j j�|� | �|�}| j j�|� d S r )r r �append�formatr )r �record�msgr r r �emit s z_CapturingHandler.emitN)�__name__� __module__�__qualname__r r r r r r r r s r c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �_AssertLogsContextz"%(levelname)s:%(name)s:%(message)sc C s: t �| |� || _|r(tj�||�| _ntj| _d | _d S r ) r r �logger_namer Z_nameToLevel�get�level�INFOr )r Z test_caser r r r r r ! s z_AssertLogsContext.__init__c C s� t | jtj�r| j }| _nt�| j� }| _t�| j�}t� }|� |� |j | _ |jd d � | _|j | _|j| _|g|_|�| j � d|_|j S )NF)� isinstancer r ZLogger�loggerZ getLoggerZ Formatter�LOGGING_FORMATr ZsetFormatterr �handlers�old_handlersr � old_level� propagate� old_propagate�setLevel)r r Z formatterZhandlerr r r � __enter__* s z_AssertLogsContext.__enter__c C s` | j | j_| j| j_| j�| j� |d ur.dS t| jj �dkr\| � d�t� | j�| jj�� d S )NFr z-no logs of level {} or higher triggered on {})r# r r"