Файловый менеджер - Редактировать - /usr/lib64/python3.6/site-packages/samba/subunit/__pycache__/run.cpython-36.opt-1.pyc
Ðазад
3 �I�dc` � @ s( d Z ddlZddlZddlZddlZG dd� dej�Zddd�Zddd �Zd d� Z ej Z ejZe e dd�dkr�yddlZej� Z ejZd ZW q� ek r� dZY q�X nd ZdZdZdZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zedk�r$edejejd� dS )znRun a unittest testcase reporting results as Subunit. $ python -m samba.subunit.run mylib.tests.test_suite � Nc sf e Zd ZdZdd� Zddd�Zdd� Z� fd d �Z� fdd�Zd d� Z dd� Z dd� Zdd� Z� Z S )�TestProtocolClienta� A TestResult which generates a subunit stream for a test run. # Get a TestSuite or TestCase to run suite = make_suite() # Create a stream (any object with a 'write' method). This should accept # bytes not strings: subunit is a byte orientated protocol. stream = open('tests.log', 'wb') # Create a subunit result object which will output to the stream result = subunit.TestProtocolClient(stream) # Optionally, to get timing data for performance analysis, wrap the # serialiser with a timing decorator result = subunit.test_results.AutoTimingTestResultDecorator(result) # Run the test suite reporting to the subunit result object suite.run(result) # Close the stream. stream.close() c C s t jj| � || _g | _d S )N)�unittest� TestResult�__init__�_stream� successes)�self�stream� r �/usr/lib64/python3.6/run.pyr 4 s zTestProtocolClient.__init__Nc C st | j jd| |j� � |rd| j jd� x.|D ]&}| j j|� |jd�s.| j jd� q.W | j jd� | j jd� dS )z�Report an outcome of test test. :param outcome: A string describing the outcome - used as the event name in the subunit stream. :param errors: A list of strings describing the errors. z%s: z [ � �]N)r �write�id�endswith)r �outcome�test�errors�errorr r r �_addOutcome9 s zTestProtocolClient._addOutcomec C s | j j|� dS )zReport a success in a test.N)r �append)r r r r r � addSuccessJ s zTestProtocolClient.addSuccessc s6 t t| �j|� | jjd|j� d � | jj� dS )z%Mark a test as starting its test run.ztest: r N)�superr � startTestr r r �flush)r r )� __class__r r r N s zTestProtocolClient.startTestc s t t| �j|� | j|� dS )z,Mark a test as having finished its test run.N)r r �stopTest�writeOutcome)r r )r r r r T s zTestProtocolClient.stopTestc C s� | j || j�\}| _| j || j�\}| _| j || j�\}| _| j || j�\}| _| j|| j�\}| _| j|| j�\}| _|r�d}n6|r�d}n,|r�d}n"|r�d}n|r�d}n|r�d}nd}|r�| j|||| | | d� | j j � dS ) z)Output the overall outcome for test test.r Zfailure�skip� uxsuccess�xfailZ successfulN)r )� _filterErrorsr ZfailuresZexpectedFailuresZskipped�_filterSuccessesr ZunexpectedSuccessesr r r ) r r �errZfailr r �successr r r r r r Y s, zTestProtocolClient.writeOutcomec C sD g }g }x2|D ]*}|d |kr.|j |d � q|j |� qW ||fS )a^ Filter a list of errors by test test. :param test: The test to filter by. :param errors: A list of <test, error> pairs to filter. :return: A pair whose first element is a list of strings containing errors that apply to test test, and whose second element is a list of the remaining elements. r � )r )r r r �filtered� unfilteredr r r r r! v s z TestProtocolClient._filterErrorsc C s6 d}g }x$|D ]}||kr d}q|j |� qW ||fS )ab Filter a list of successes by test test. :param test: The test to filter by. :param successes: A list of tests to filter. :return: A tuple whose first element is a boolean stating whether test test was found in the list of successes, and whose second element is a list of the remaining elements. FT)r )r r r r&