← Back
Editing: test_suppression.cpython-38.pyc
U W[� � @ sh d Z ddlmZmZ ddlZddlmZ ddlmZ ddl m Z G dd� de�ZG d d � d eej �ZdS )z2 Tests for warning suppression features of Trial. � )�division�absolute_importN)�namedAny)�unittest)�suppressionc @ sX e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� ZdS )�SuppressionMixinzj Tests for the warning suppression features of L{twisted.trial.unittest.SynchronousTestCase}. c C s |� t�� � d S )N)�run�pyunitZ TestResult)�selfZsuite� r �E/usr/lib/python3/dist-packages/twisted/trial/test/test_suppression.py�runTests s zSuppressionMixin.runTestsc C s t �||�g�S )z� Return a new L{unittest.TestSuite} with a single test method in it. @param cls: A L{TestCase} subclass defining a test method. @param methodName: The name of the test method from C{cls}. )r Z TestSuite)r �clsZ methodNamer r r �_load s zSuppressionMixin._loadc C s | � dd� |D �|� dS )a& Assert that a certain number of warnings with certain messages were emitted in a certain order. @param warnings: A list of emitted warnings, as returned by C{flushWarnings}. @param which: A list of strings giving warning messages that should appear in C{warnings}. @raise self.failureException: If the warning messages given by C{which} do not match the messages in the warning information in C{warnings}, or if they do not appear in the same order. c S s g | ]}|d �qS )�messager )�.0Zwarningr r r � <listcomp>5 s z4SuppressionMixin._assertWarnings.<locals>.<listcomp>N)�assertEqual)r �warningsZwhichr r r �_assertWarnings% s �z SuppressionMixin._assertWarningsc C sD | � | �| jd�� | �| jjg�}| �|tjtjtjtjg� dS )z� Suppressions defined by the test method being run are applied to any warnings emitted while running the C{setUp} fixture. �testSuppressMethodN) r r �TestSetUpSuppression� flushWarnings�_emitr r �CLASS_WARNING_MSG�MODULE_WARNING_MSG�r Z warningsShownr r r �test_setUpSuppression9 s �� ��z&SuppressionMixin.test_setUpSuppressionc C sD | � | �| jd�� | �| jjg�}| �|tjtjtjtjg� dS )z� Suppressions defined by the test method being run are applied to any warnings emitted while running the C{tearDown} fixture. r N) r r �TestTearDownSuppressionr r r r r r r r r r �test_tearDownSuppressionH s �� ��z)SuppressionMixin.test_tearDownSuppressionc C s<