File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_iutils.cpython-310.pyc
o
�b@5 � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z m
Z
mZmZ ddl
mZ ddlmZ ddlmZ ddlmZmZ G d d
� d
e�ZG dd� de�ZG d
d� de�ZdS )zD
Test running processes with the APIs in L{twisted.internet.utils}.
� N)�skipIf)�error�
interfaces�reactor�utils)�Deferred)�platform)�SuppressedWarningsTests)�SynchronousTestCase�TestCasec @ s� e Zd ZdZe�ed�du rdZdZdZ e
jZdd� Z
dd� Zdd � Zd
d� Zdd
� Zdd� Zee�� d�dd� �Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� ZdS )%�ProcessUtilsTestszt
Test running a process using L{getProcessOutput}, L{getProcessValue}, and
L{getProcessOutputAndValue}.
Nz)reactor doesn't implement IReactorProcessc C sV | � � }t|d��}|�tj�|�tj � W d � n1 s w Y tj�|�S )zj
Write the given list of lines to a text file and return the absolute
path to it.
�wtN)�mktemp�open�write�os�linesep�join�path�abspath)�self�sourceLines�script�
scriptFile� r �:/usr/lib/python3/dist-packages/twisted/test/test_iutils.py�makeSourceFile$ s
�z ProcessUtilsTests.makeSourceFilec C s. | � g d��}t�| jd|g�}|�| jd�S )z�
L{getProcessOutput} returns a L{Deferred} which fires with the complete
output of the process it runs after that process exits.
)�
import syszfor s in b'hello world\n':z s = bytes([s])z sys.stdout.buffer.write(s)z sys.stdout.flush()�-us hello world
�r r �getProcessOutput�exe�addCallback�assertEqual�r r �dr r r �test_output. s
� zProcessUtilsTests.test_outputc sF � � ddg�}t�� jd|g�}� �|t�}� fdd�}|�|� |S )z�
The L{Deferred} returned by L{getProcessOutput} is fired with an
L{IOError} L{Failure} if the child process writes to stderr.
r z!sys.stderr.write("hello world\n")r c s � � | jtj�S �N)�
assertFailure�processEndedr �ProcessDone)�err�r r r �cbFailedL � z?ProcessUtilsTests.test_outputWithErrorIgnored.<locals>.cbFailed)r r r r! r( �IOErrorr"