관리-도구
편집 파일: logcapture.cpython-37.pyc
B /�Se�$ � @ s� d Z ddlZddlmZ ddlZddlmZ ddlmZmZm Z yddl mZ W n ek rp ddl mZ Y nX e� e�ZG dd� de�ZG d d � d e�ZG dd� de�ZdS ) a This plugin captures logging statements issued during test execution. When an error or failure occurs, the captured log messages are attached to the running test in the test.capturedLogging attribute, and displayed with the error failure output. It is enabled by default but can be turned off with the option ``--nologcapture``. You can filter captured logging statements with the ``--logging-filter`` option. If set, it specifies which logger(s) will be captured; loggers that do not match will be passed. Example: specifying ``--logging-filter=sqlalchemy,myapp`` will ensure that only statements logged via sqlalchemy.engine, myapp or myapp.foo.bar logger will be logged. You can remove other installed logging handlers with the ``--logging-clear-handlers`` option. � N)�Handler)�Plugin)�anyp�ln�safe_str)�StringIOc @ sL e Zd Zdd� Zdd� Zee�Zdd� Zdd� Zee�Zd d � Zdd� Z d S )� FilterSetc C s | � |�\| _| _d S )N)� _partition� inclusive� exclusive)�selfZfilter_components� r �H/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/logcapture.py�__init__! s zFilterSet.__init__c C sH g g }}x4| D ],}|� d�r2|�|dd � � q|�|� qW ||fS )N�-� )� startswith�append)� componentsr r Z componentr r r r % s zFilterSet._partitionc C s | sdS | � |�o| �|� S )z-returns whether this record should be printedT)�_allow�_deny)r �recordr r r �allow/ s zFilterSet.allowc s � fdd�}t ttt|| ���S )zNreturn the bool of whether `record` starts with any item in `matchers`c s � | kp� � | d �S )N�.)r )�key)r r r �record_matches_key: s z0FilterSet._any_match.<locals>.record_matches_key)r �bool�list�map)Zmatchersr r r )r r � _any_match7 s zFilterSet._any_matchc C s | j s dS | �| j |�S )NT)r r )r r r r r r ? s zFilterSet._allowc C s | j s dS | �| j |�S )NF)r r )r r r r r r D s zFilterSet._denyN) �__name__� __module__�__qualname__r r �staticmethodr r r r r r r r r s r c @ sD e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dS )�MyMemoryHandlerc C s4 t �| � t�||�}| �|� t|�| _g | _d S )N)r r �logging� Formatter�setFormatterr � filterset�buffer)r � logformat� logdatefmt�filters�fmtr r r r K s zMyMemoryHandler.__init__c C s | j �| �|�� d S )N)r) r �format)r r r r r �emitQ s zMyMemoryHandler.emitc C s d S )Nr )r r r r �flushS s zMyMemoryHandler.flushc C s g | _ d S )N)r) )r r r r �truncateU s zMyMemoryHandler.truncatec C s | j �|j�rt�| |�S d S )N)r( r �namer �filter)r r r r r r3 W s zMyMemoryHandler.filterc C s | j �� }|d= |S )N�lock)�__dict__�copy)r �stater r r �__getstate__Z s zMyMemoryHandler.__getstate__c C s | j �|� t�� | _d S )N)r5 �update� threading�RLockr4 )r r7 r r r �__setstate__^ s zMyMemoryHandler.__setstate__N) r r! r"