File: //usr/lib/python3/dist-packages/twisted/trial/_dist/__pycache__/worker.cpython-38.pyc
U
W[�# � @ s d Z ddlZddlmZ ddlmZ ddlmZmZ ddl m
Z
ddlmZ ddl
mZ dd lmZ dd
lmZ ddlmZmZ ddlmZmZ dd
lmZmZ ddlmZ G dd� de�ZG dd� de�Zee�G dd� de��Z ee�G dd� de��Z!G dd� de�Z"dS )z:
This module implements the worker classes.
@since: 12.3
� N)�implementer)�ProcessProtocol)�
ITransport�IAddress)�Deferred)�AMP)�Failure)�namedObject)�Todo)�
TrialSuite�
TestLoader)�workercommands�managercommands)�_WORKER_AMP_STDIN�_WORKER_AMP_STDOUT)�WorkerReporterc @ sB e Zd ZdZd
dd�Zdd� Zej�e� dd� Z ej
�e � d S )�WorkerProtocolz5
The worker-side trial distributed protocol.
Fc C s t � | _t| �| _|| _d S �N)r �_loaderr �_result�_forceGarbageCollection)�selfZforceGarbageCollection� r �</usr/lib/python3/dist-packages/twisted/trial/_dist/worker.py�__init__# s
zWorkerProtocol.__init__c C s. | j �|�}t|g| j�}|�| j� ddiS )z*
Run a test case by name.
�successT)r Z
loadByNamer r �runr )r �testCaseZcaseZsuiter r r r ) s zWorkerProtocol.runc C s t �|� ddiS )zb
Set up the worker, moving into given directory for tests to run in
them.
r T)�os�chdir)r � directoryr r r �start5 s
zWorkerProtocol.startN)F)�__name__�
__module__�__qualname__�__doc__r r r
�Run� responderr! �Startr r r r r s
r c @ s� e Zd ZdZdd� Zej�e� dd� Zdd� Z ej
�e � dd � Zej�e� d
d� Z
ej�e
� dd
� Zej�e� dd� Zej�e� dd� Zej�e� dd� Zdd� Zdd� ZdS )�LocalWorkerAMPz7
Local implementation of the manager commands.
c C s | j �| j� ddiS )z0
Add a success to the reporter.
r T)r �
addSuccess� _testCase)r �testNamer r r r* F s zLocalWorkerAMP.addSuccessc C sZ t |�}t||�}tdt|�d�D ]2}|j�|| ||d t||d �g g f� q"|S )a�
Helper to build a C{Failure} with some traceback.
@param error: An C{Exception} instance.
@param error: The class name of the C{error} class.
@param frames: A flat list of strings representing the information need
to approximatively rebuild C{Failure} frames.
@return: A L{Failure} instance with enough information about a test
error.
r � � � )r r �range�len�frames�append�int)r �error�
errorClassr2 Z errorType�failure�ir r r �
_buildFailureP s
$�zLocalWorkerAMP._buildFailurec C s&