File: //lib/python3/dist-packages/samba/subunit/__pycache__/run.cpython-310.pyc
o
�/ad` � @ s& d Z ddlZddlZddlZddlZG dd� dej�Zddd�Zddd �Zd
d� Z ej
Z
ejZe
e
dd�du rRzddlZe�� Z
ejZd
ZW n
eyQ dZY nw d
ZdZdZdZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zedkr�edejejd� dS 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 j�| � || _g | _d S �N)�unittest�
TestResult�__init__�_stream� successes)�self�stream� r �3/usr/lib/python3/dist-packages/samba/subunit/run.pyr 4 s
zTestProtocolClient.__init__Nc C sp | j �d| |�� � |r0| j �d� |D ]}| j �|� |�d�s)| j �d� q| j �d� | j �d� 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 �|� dS )zReport a success in a test.N)r �append�r r r r r �
addSuccessJ s zTestProtocolClient.addSuccessc s6 t t| ��|� | j�d|�� d � | j�� dS )z%Mark a test as starting its test run.ztest: r
N)�superr � startTestr r r �flushr �� __class__r r r N s zTestProtocolClient.startTestc s t t| ��|� | �|� dS )z,Mark a test as having finished its test run.N)r r �stopTest�writeOutcomer r r r r T s zTestProtocolClient.stopTestc C s� | � || j�\}| _| � || j�\}| _| � || j�\}| _| � || j�\}| _| �|| j�\}| _| �|| j�\}| _|rAd}n|rFd}n|rKd}n|rPd}n|rUd}n|rZd}nd}|rl| j|||| | | d� | j �
� dS ) z)Output the overall outcome for test test.r �failure�skip� uxsuccess�xfail�
successfulN)r )�
_filterErrorsr �failures�expectedFailures�skipped�_filterSuccessesr �unexpectedSuccessesr r r ) r r �err�failr$ r"