File: //usr/lib/python3/dist-packages/twisted/logger/test/__pycache__/test_global.cpython-38.pyc
U
�`�[/ � @ s� d Z ddlmZ ddlZddlmZ ddlmZ ddlm Z ddl
mZ dd lm
Z
dd
lmZ ddlmZ ddlmZ dd
lmZ dd� ZG dd� dej�ZdS )z+
Test cases for L{twisted.logger._global}.
� )�print_functionN)�unittest� )�textFileLogObserver)�LogPublisher)�Logger)�LogBeginner)�MORE_THAN_ONCE_WARNING)�LogLevel)�nextLine)�Failurec sj t |�t |�kr| �||� t� � |D ]}� t|�� �O � q&� fdd���fdd�|D �}| �||� dS )a�
Compare two sequences of log events, examining only the the keys which are
present in both.
@param test: a test case doing the comparison
@type test: L{unittest.TestCase}
@param actualEvents: A list of log events that were emitted by a logger.
@type actualEvents: L{list} of L{dict}
@param expectedEvents: A list of log events that were expected by a test.
@type expected: L{list} of L{dict}
c s, | � � }| �� D ]}|� kr|�|� q|S �N)�copy�keys�pop)�eventr �key)�
allMergedKeys� �A/usr/lib/python3/dist-packages/twisted/logger/test/test_global.py�simplify. s
zcompareEvents.<locals>.simplifyc s g | ]}� |��qS r r ��.0r )r r r �
<listcomp>5 s z!compareEvents.<locals>.<listcomp>N)�len�assertEqual�setr )ZtestZactualEventsZexpectedEventsr ZsimplifiedActualr )r r r �
compareEvents s r c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� ZdS )�LogBeginnerTestsz#
Tests for L{LogBeginner}.
c C s^ t � | _t�� | _G dd� dt�}G dd� dt�}|� | _|� | _t| j| j| j| j�| _ d S )Nc @ s e Zd Ze� Ze� ZdS )z&LogBeginnerTests.setUp.<locals>.NotSysN)�__name__�
__module__�__qualname__�object�stdout�stderrr r r r �NotSysC s r% c @ s e Zd Zdd� Zddd�ZdS )z+LogBeginnerTests.setUp.<locals>.NotWarningsc S s
g | _ d S r
)�warnings)�selfr r r �__init__H s z4LogBeginnerTests.setUp.<locals>.NotWarnings.__init__Nc S s | j �||||||f� dS )a�
Emulate warnings.showwarning.
@param message: A warning message to emit.
@type message: L{str}
@param category: A warning category to associate with
C{message}.
@type category: L{warnings.Warning}
@param filename: A file name for the source code file issuing
the warning.
@type warning: L{str}
@param lineno: A line number in the source file where the
warning was issued.
@type lineno: L{int}
@param file: A file to write the warning message to. If
L{None}, write to L{sys.stderr}.
@type file: file-like object
@param line: A line of source code to include with the warning
message. If L{None}, attempt to read the line from
C{filename} and C{lineno}.
@type line: L{str}
N)r&