Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/testfixtures/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/testfixtures/__pycache__/popen.cpython-37.pyc

B

R�X��@sfddlmZddlmZddlmZddlmZddlm	Z	Gdd�de
�ZdZe	eej
ejg�d	S)
�)�Mock)�Popen)�
TemporaryFile)�
basestring)�extend_docstringc
@steZdZdZdZdd�Zdd	d
�Zddd�Zd
d�Zd dd�Z	dd�Z
d!dd�Zdd�Zdd�Z
dd�Zdd�ZdS)"�	MockPopenz�
    A specialised mock for testing use of :class:`subprocess.Popen`.
    An instance of this class can be used in place of the
    :class:`subprocess.Popen` and is often inserted where it's needed using
    :func:`mock.patch` or a :class:`Replacer`.
    NcCsxi|_t�|_}|j|jj_ttd�|_|j}|j_|j|j_|j|j_|j	|j	_|j
|j
_|j|j_|j|j_dS)N)�spec)
�commandsr�mockrZside_effect�Popen_instanceZreturn_value�communicate�wait�send_signal�	terminate�kill�poll)�selfr
�inst�r�C/opt/alt/python37/lib/python3.7/site-packages/testfixtures/popen.py�__init__s




zMockPopen.__init__�r���cCs|||||f|j|<dS)z�
        Set the behaviour of this mock when it is used to simulate the
        specified command.

        :param command: A string representing the command to be simulated.
        N)r	)r�command�stdout�stderr�
returncode�pid�
poll_countrrr�set_command!szMockPopen.set_commandcCs|||||f|_dS)z�
        Set the behaviour of this mock when it is used to simulate commands
        that have no explicit behavior specified using
        :meth:`~MockPopen.set_command`.
        N)�default_command)rrrrrrrrr�set_default+szMockPopen.set_defaultcOs|jj||�S)N)r
r)r�args�kwrrr�__call__4szMockPopen.__call__FcCs�t|t�r|}n
d�|�}|j�||j�}|dkr>td|��|\|_|_|_	}}||_
xDdD]<}t�}|�t
||��|��|�d�t|jj||�q^W||jj_d|jj_	|jjS)N� z Nothing specified for command %r)rrr)�
isinstancer�joinr	�getr!�KeyErrorrrrrr�write�getattr�flush�seek�setattrr
rr)rr#�bufsize�
executable�stdinrr�
preexec_fn�	close_fds�shell�cwd�env�universal_newlines�startupinfo�
creationflags�cmdZ	behaviourrr�name�frrrr7s"





zMockPopen.PopencCs|j|jj_|jS)z/Simulate calls to :meth:`subprocess.Popen.wait`)rr
r)rrrrr
TszMockPopen.waitcCs|��|j|jfS)z6Simulate calls to :meth:`subprocess.Popen.communicate`)r
rr)r�inputrrrrYszMockPopen.communicatecCs2x(|jr(|jjjdkr(|jd8_dSW|��S)z/Simulate calls to :meth:`subprocess.Popen.poll`N�)rr
rrr
)rrrrr^szMockPopen.pollcCsdS)z6Simulate calls to :meth:`subprocess.Popen.send_signal`Nr)r�signalrrrrjszMockPopen.send_signalcCsdS)z4Simulate calls to :meth:`subprocess.Popen.terminate`Nr)rrrrrnszMockPopen.terminatecCsdS)z/Simulate calls to :meth:`subprocess.Popen.kill`Nr)rrrrrrszMockPopen.kill)rrrrr)rrrrr)
rNNNNNFFNNFNr)N)�__name__�
__module__�__qualname__�__doc__r!rr r"r%rr
rrrrrrrrrr
s&

	


ra�
:param stdout:
    A string representing the simulated content written by the process
    to the stdout pipe.
:param stderr:
    A string representing the simulated content written by the process
    to the stderr pipe.
:param returncode:
    An integer representing the return code of the simulated process.
:param pid:
    An integer representing the process identifier of the simulated
    process. This is useful if you have code the prints out the pids
    of running processes.
:param poll_count:
    Specifies the number of times :meth:`MockPopen.poll` can be
    called before :attr:`MockPopen.returncode` is set and returned
    by :meth:`MockPopen.poll`.
N)r
r�
subprocessr�tempfilerZtestfixtures.compatrZtestfixtures.utilsr�objectrZset_command_paramsr r"rrrr�<module>s~