Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures/__pycache__/popen.cpython-311.pyc

�

�܋f�'��v�ddlZddlmZmZmZddlmZddlmZm	Z	ddl
mZmZddl
mZddlmZddlmZmZmZmZmZmZmZd	d
lmZmZmZeeefZ eeeefZ!de!defd
�Z"Gd�de#��Z$defd�Z%Gd�de#��Z&Gd�de#��Z'dZ(ee(e'j)e'j*g��dS)�N)�wraps�partial�reduce)�
TextIOWrapper)�chain�zip_longest)�STDOUT�PIPE)�
TemporaryFile)�extend_docstring)�Union�Callable�List�Optional�Sequence�Tuple�Dict�)�Mock�call�_Call�command�returnc�n�t|t��sd�d�|D����}|S)N� c3�>K�|]}tj|��V��dS�N)�pipes�quote)�.0�parts  �c/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/testfixtures/popen.py�	<genexpr>zshell_join.<locals>.<genexpr>s,����A�A��5�;�t�,�,�A�A�A�A�A�A�)�
isinstance�str�join)rs r"�
shell_joinr(s:���g�s�#�#�B��(�(�A�A��A�A�A�A�A���Nr$c�:�eZdZdZ					d
dededed	ed
ef
d�ZdS)�PopenBehaviourzp
    An object representing the behaviour of a :class:`MockPopen` when
    simulating a particular command.
    r$r����stdout�stderr�
returncode�pid�
poll_countc�L�||_||_||_||_||_dSr)r-r.r/r0r1)�selfr-r.r/r0r1s      r"�__init__zPopenBehaviour.__init__s+��������$������$����r$N)r$r$rr+r,)�__name__�
__module__�__qualname__�__doc__�bytes�intr4�r$r"r*r*sx�������� �����
%�%��%��%��	%�
�%��
%�%�%�%�%�%r$r*c�<��t����fd���}|S)Nc�J��|j�jfg|�Ri|���|g|�Ri|��Sr)�_recordr5)r3�args�kw�funcs   �r"�recorderzrecord.<locals>.recorder,sJ������d�m�%�3��3�3�3��3�3�3��t�D�&�4�&�&�&�2�&�&�&r$)r)rArBs` r"�recordrC+s3���
�4�[�[�'�'�'�'��[�'��Or$c
�6�eZdZUdZdZeed<dZeed<dZ	eed<							dd
�Z
d�Zd�Zd
�Z
eddedefd���Zeddededeeeffd���Zedeefd���Zededdfd���Zedd���Zedd���ZdS)�MockPopenInstancez;
    A mock process as returned by :class:`MockPopen`.
    N�stdinr-r.rFTr;c�h�t��|_|jj|_||_g|_|j|_t|��}|j�	||j
��}|�td|z���t|��r
|||���}||_
|j}|j}|t krit#jt'|�d��|�d������}d�d�|D����}d}|j|_d||fd||ffD]�\}}}d}|t.urdt1��}|�|��|���|�d��|s|s|rt9|||�	��}t;|||����|t.krIt��|_d
D]3} t?|j d| f��}!|!tC|j| ��_"�4|j#|_#d|_$||_%dS)Nz Nothing specified for command %r)rrFTr$c3�K�|]}|�|V��	dSrr;)r �ls  r"r#z-MockPopenInstance.__init__.<locals>.<genexpr>is'����#B�#B�!��#B�A�#B�#B�#B�#B�#B�#Br$r-r.r)�encoding�errors)�write�closerF)&r�mock�Popen_instance�class_instance_mock�	root_call�calls�	all_callsr(�commands�get�default_behaviour�KeyError�callable�	behaviourr-r.r	r�
from_iterabler�
splitlinesr'r1r
rrL�flush�seekr�setattrrFrr>�getattr�side_effectr0r/r?)"r3�
mock_classrQr?�bufsize�
executablerFr-r.�
preexec_fn�	close_fds�shell�cwd�env�universal_newlines�startupinfo�
creationflags�restore_signals�start_new_session�pass_fdsrJrK�text�cmdrY�stdout_value�stderr_value�
line_iterator�name�option�
mock_value�value�method�
record_writess"                                  r"r4zMockPopenInstance.__init__DsS���&�&��	�)3��)G�� � )���"$��
�%/�%9���������'�+�+�C��1M�N�N�	����=��C�D�D�D��I���	<�!�	�#�U�;�;�;�I�)2��� �'�� �'���V���!�/���'�'��-�-��'�'��-�-�1�1���M��8�8�#B�#B�}�#B�#B�#B�B�B�L��L�(�3���
�v�|�,�
�v�|�,�)
�	'�	'�$�D�&�*��E���~�~�%�������J�'�'�'����
�
�
��
�
�1�
�
�
�%�S��S��S�)�%�(�6�R�R�R�E��D�$��&�&�&�&��D�=�=����D�J�*�
H�
H�� '���w��6G� H� H�
�:G���
�F�+�+�7�7�!�
���)-���!��	�	�	r$c	��|j|jfD]}tt||��|i|���t|jf|j|jffD]4\}}|�tt||��|i|�����5dSr)	rPrNrr_rrRrQrS�append)r3�namesr?r@rN�	base_call�stores       r"r>zMockPopenInstance._record�s����,�d�i�7�	6�	6�D�(�F�7�E�4�(�(�$�5�"�5�5�5�5�
�4�:��
�^�T�^�,�!
�	I�	I��I�u�
�L�L�:����	�:�:�D�G�B�G�G�H�H�H�H�		I�	Ir$c��|Srr;�r3s r"�	__enter__zMockPopenInstance.__enter__�s���r$c�|�|���|j|jfD]}|r|����dSr)�waitr-r.rM)r3�exc_type�exc_val�exc_tb�streams     r"�__exit__zMockPopenInstance.__exit__�sG���	�	�����k�4�;�.�	�	�F��
��������	�	r$�timeoutrc�2�|jj|_|jS)z/Simulate calls to :meth:`subprocess.Popen.wait`)rYr/)r3r�s  r"r�zMockPopenInstance.wait�s���.�3�����r$�inputc��|jj|_|jo|j���|jo|j���fS)z6Simulate calls to :meth:`subprocess.Popen.communicate`)rYr/r-�readr.)r3r�r�s   r"�communicatezMockPopenInstance.communicate�sJ���.�3�����2��� 0� 0� 2� 2���2��� 0� 0� 2� 2�4�	4r$c�r�|jr|j�|xjdzc_dS|jj|_|jS)z/Simulate calls to :meth:`subprocess.Popen.poll`Nr)r1r/rYr�s r"�pollzMockPopenInstance.poll�s@���o�	�$�/�"9��O�O�q� �O�O��4�
�.�3�����r$�signalc��dS)z6Simulate calls to :meth:`subprocess.Popen.send_signal`Nr;)r3r�s  r"�send_signalzMockPopenInstance.send_signal��	��	
�r$c��dS)z4Simulate calls to :meth:`subprocess.Popen.terminate`Nr;r�s r"�	terminatezMockPopenInstance.terminate�r�r$c��dS)z/Simulate calls to :meth:`subprocess.Popen.kill`Nr;r�s r"�killzMockPopenInstance.kill�r�r$)rNNNNNFFNNFNrTFr;NNNr)NN)rN)r5r6r7r8rFr�__annotations__r-rr.r4r>r�r�rC�floatr:r��AnyStrrr�rr�r�r�r�r;r$r"rErE3s�����������E�4����!�F�M� � � �!�F�M� � � �.2�15�DH�.3�DH�35�26�@"�@"�@"�@"�DI�I�I����������E��S�����V��
�4�4��4��4�%�PV�X^�P^�J_�4�4�4��V�4��
�h�s�m�
�
�
��V�
��
�#�
�$�
�
�
��V�
��
�
�
��V�
��
�
�
��V�
�
�
r$rEc��eZdZUdZdZeed<d�Zd�Z						dd
e	de
de
d
edededeee
ffd�Z		dd�Zd�ZdS)�	MockPopena
    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:`unittest.mock.patch` or a :class:`~testfixtures.Replacer`.
    NrVc�H�i|_t��|_g|_dSr)rTrrNrSr�s r"r4zMockPopen.__init__�s!��35��
��&�&��	�&(����r$c�0�|�t|||||��S|Sr)r*�r3r-r.r/r0r1rYs       r"�_resolve_behaviourzMockPopen._resolve_behaviour�s-����!���
�C����
��r$r$rr+r,rr-r.r/r0r1rYc�d�|�||||||��|jt|��<dS)z�
        Set the behaviour of this mock when it is used to simulate the
        specified command.

        :param command: A :class:`str` representing the command to be simulated.
        N)r�rTr()r3rr-r.r/r0r1rYs        r"�set_commandzMockPopen.set_command�s;�� .2�-D�-D��F�J��Z��.
�.
��
�j��)�)�*�*�*r$c�D�|�||||||��|_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)r�rVr�s       r"�set_defaultzMockPopen.set_default�s/��"&�!8�!8��F�J��Z��"
�"
����r$c��|jj|i|��tj|i|��}|j�|��t||g|�Ri|��Sr)rN�PopenrrSr{rE)r3r?r@rQs    r"�__call__zMockPopen.__call__�se����	���$��$�$�$��J��+��+�+�	�����i�(�(�(� ��y�>�4�>�>�>�2�>�>�>r$)r$r$rr+r,N)r5r6r7r8rVr*r�r4r�r&r9r:r
rr�r�r�r;r$r"r�r��s����������)-��~�,�,�,�(�(�(���� �����9=�
�
��
��
��	
�
�
��

��
��^�X�5�6�
�
�
�
�(>?�6:�	
�	
�	
�	
�?�?�?�?�?r$r�a�
:param stdout:
    :class:`bytes` representing the simulated content written by the process
    to the stdout pipe.
:param stderr:
    :class:`bytes` 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:`~MockPopenInstance.poll` can be
    called before :attr:`~MockPopenInstance.returncode` is set and returned
    by :meth:`~MockPopenInstance.poll`.

If supplied, ``behaviour`` must be either a :class:`PopenBehaviour`
instance or a callable that takes the ``command`` string representing
the command to be simulated and the ``stdin`` supplied when instantiating
the :class:`subprocess.Popen` with that command and should
return a :class:`PopenBehaviour` instance.
)+r�	functoolsrrr�ior�	itertoolsrr�
subprocessr	r
�tempfiler�testfixtures.utilsr�typingr
rrrrrrrNrrr�Callr&r9r��Commandr(�objectr*rCrEr��set_command_paramsr�r�r;r$r"�<module>r�s
������,�,�,�,�,�,�,�,�,�,�������(�(�(�(�(�(�(�(�#�#�#�#�#�#�#�#�"�"�"�"�"�"�/�/�/�/�/�/�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�+�+�+�+�+�+�+�+�+�+�
�s�E�z�	��
��X�c�]�"�
#�����C�����%�%�%�%�%�V�%�%�%�*�H�����L
�L
�L
�L
�L
��L
�L
�L
�^=?�=?�=?�=?�=?��=?�=?�=?�@��6��#��'��)>�?�A�A�A�A�Ar$

Hacked By AnonymousFox1.0, Coded By AnonymousFox