File: //usr/lib/python3/dist-packages/twisted/trial/_dist/__pycache__/disttrial.cpython-310.pyc
o
�bn! � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZ dd
lmZmZ ddlmZ ddlmZ G d
d� d�ZdS )z�
This module contains the trial distributed runner, the management class
responsible for coordinating all of trial's behavior at the highest level.
@since: 12.3
� N)�DeferredList�� cooperate)�FilePath)�
theSystemPath)�
_iterateTests)�_WORKER_AMP_STDIN�_WORKER_AMP_STDOUT)�DistReporter)�LocalWorker�LocalWorkerAMP)�UncleanWarningsReporterWrapper)�_unusedTestDirectoryc @ sj e Zd ZdZeZdd� Z dd d
�Zdd� Zd
d� Z dd� Z
dd� Zdedfdd�Z
dd� ZdS )�DistTrialRunneraY
A specialized runner for distributed trial. The runner launches a number of
local worker processes which will run tests.
@ivar _workerNumber: the number of workers to be spawned.
@type _workerNumber: C{int}
@ivar _stream: stream which the reporter will use.
@ivar _reporterFactory: the reporter class to be used.
c C s. | j | j| j| jd�}| jrt|�}| �|�S )zL
Make reporter factory, and wrap it with a L{DistReporter}.
)�realtime)�_reporterFactory�_stream� _tbformat� _rterrors�_uncleanWarningsr
�_distReporterFactory)�self�reporter� r �?/usr/lib/python3/dist-packages/twisted/trial/_dist/disttrial.py�_makeResult* s �
zDistTrialRunner._makeResultN�defaultF�test.log�_trial_tempc
C s` || _ || _|| _|d u rtj}|| _|| _|| _|| _d | _ | | _
|| _d | _d | _
d| _d S )NF)�
_workerNumber�_workerArgumentsr �sys�stdoutr r r r �_result�_workingDirectory�_logFile�_logFileObserver�_logFileObject�_logWarnings)
r �reporterFactory�workerNumber�workerArguments�stream�tracebackFormat�realTimeErrors�uncleanWarnings�logfile�workingDirectoryr r r �__init__5 s
zDistTrialRunner.__init__c C s |� � dS )z�
Write test run final outcome to result.
@param result: A C{TestResult} which will print errors and the summary.
N)�done)r �resultr r r �writeResultsQ s zDistTrialRunner.writeResultsc s � �fdd�t |�D �S )aY
Create local worker protocol instances and return them.
@param protocols: An iterable of L{LocalWorkerAMP} instances.
@param workingDirectory: The base path in which we should run the
workers.
@type workingDirectory: C{str}
@return: A list of C{quantity} C{LocalWorker} instances.
c s, g | ]\}}t |tj��t|��� j��qS r )r �os�path�join�strr% )�.0�x�protocol�r r1 r r �
<listcomp>e s ��z6DistTrialRunner.createLocalWorkers.<locals>.<listcomp>)� enumerate)r � protocolsr1 r r= r �createLocalWorkersY s �z"DistTrialRunner.createLocalWorkersc
C sv t d jj}ddddddtdtdi}tj�� }tj� t
j�|d<