← Back
Editing: test_filter.cpython-38.pyc
U W[�. � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlmZ ddl m Z ddl mZ dd lm Z dd lmZ ddlmZ G dd � d ej�ZG dd� dej�ZdS )z+ Test cases for L{twisted.logger._filter}. � )�verifyObject�BrokenMethodImplementation)�unittest� )�InvalidLogLevelError)�LogLevel)�ILogObserver)�LogPublisher��FilteringLogObserver)�PredicateResult)�LogLevelFilterPredicatec @ sj e Zd ZdZdd� Zddd�Zdd� Zd d � Zdd� Zd d� Z dd� Z dd� Zdd� Zdd� Z dd� ZdS )�FilteringLogObserverTestsz, Tests for L{FilteringLogObserver}. c C sN t dd� d�}ztt|� W n, tk rH } z| �|� W 5 d}~X Y nX dS )z@ L{FilteringLogObserver} is an L{ILogObserver}. c S s d S �N� ��er r �A/usr/lib/python3/dist-packages/twisted/logger/test/test_filter.py�<lambda> � z:FilteringLogObserverTests.test_interface.<locals>.<lambda>r N)r r r r Zfail)�self�observerr r r r �test_interface s z(FilteringLogObserverTests.test_interfaceFc s� t dd�t dd�t dd�t dd�g}G dd� dt�� � fdd �|D �}g }g }|j}|rb|jg}ng }t||f|�� } |D ]} | | � qz|r�d d� |D �dd� |D �fS d d� |D �S )a Apply a set of pre-defined filters on a known set of events and return the filtered list of event numbers. The pre-defined events are four events with a C{count} attribute set to C{0}, C{1}, C{2}, and C{3}. @param filters: names of the filters to apply. Options are: - C{"twoMinus"} (count <=2), - C{"twoPlus"} (count >= 2), - C{"notTwo"} (count != 2), - C{"no"} (False). @type filters: iterable of str @param other: Whether to return a list of filtered events as well. @type other: L{bool} @return: event numbers or 2-tuple of lists of event numbers. @rtype: L{list} of L{int} or 2-L{tuple} of L{list} of L{int} r ��count� r � c @ sH e Zd Zedd� �Zedd� �Zedd� �Zedd� �Zed d � �ZdS )z5FilteringLogObserverTests.filterWith.<locals>.Filtersc S s | d dkrt jS t jS )z� count <= 2 @param event: an event @type event: dict @return: L{PredicateResult.yes} if C{event["count"] <= 2}, otherwise L{PredicateResult.maybe}. r r �r �yes�maybe��eventr r r �twoMinusJ s z>FilteringLogObserverTests.filterWith.<locals>.Filters.twoMinusc S s | d dkrt jS t jS )z� count >= 2 @param event: an event @type event: dict @return: L{PredicateResult.yes} if C{event["count"] >= 2}, otherwise L{PredicateResult.maybe}. r r r r r r r �twoPlusY s z=FilteringLogObserverTests.filterWith.<locals>.Filters.twoPlusc S s | d dkrt jS t jS )z� count != 2 @param event: an event @type event: dict @return: L{PredicateResult.yes} if C{event["count"] != 2}, otherwise L{PredicateResult.maybe}. r r )r �nor r r r r �notTwoh s z<FilteringLogObserverTests.filterWith.<locals>.Filters.notTwoc S s t jS )z� No way, man. @param event: an event @type event: dict @return: L{PredicateResult.no} �r r$ r r r r r$ w s z8FilteringLogObserverTests.filterWith.<locals>.Filters.noc S s dS )z� Bogus result. @param event: an event @type event: dict @return: something other than a valid predicate result. Nr r r r r �bogus� s z;FilteringLogObserverTests.filterWith.<locals>.Filters.bogusN) �__name__� __module__�__qualname__�staticmethodr"