a
     Rîh  ã                   @   sd   d dl Z d dlmZ d dlZd dlZejZdev r>de d ZG dd„ de jƒZe	dkr`e  
¡  dS )é    N)Úsupportú ú"c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )Ú	PopenTestc                 C   sb   d}|t |f }t |¡}| ¡ }W d   ƒ n1 s80    Y  t|ƒdd … }|  ||¡ d S )Nz&%s -c "import sys; print(sys.argv)" %sé   )ÚpythonÚosÚpopenÚreadÚevalÚassertEqual)ÚselfZcmdlineZexpectedÚcmdÚpÚdataZgot© r   ú7/opt/python-3.9.24/usr/lib/python3.9/test/test_popen.pyÚ_do_test_commandline   s    &zPopenTest._do_test_commandlinec                 C   sJ   |   ttj¡ |  dddg¡ |  dg d¢¡ |  dg d¢¡ t ¡  d S )Nzfoo barÚfooÚbarz foo "spam and eggs" "silly walk")r   zspam and eggsz
silly walkzfoo "a \"quoted\" arg" bar)r   za "quoted" argr   )ZassertRaisesÚ	TypeErrorr   r	   r   r   Úreap_children©r   r   r   r   Ú
test_popen   s    þþþzPopenTest.test_popenc                 C   sR   |   t d¡ ¡ d ¡ t d¡ ¡ }tjdkr<|   |d¡ n|   t |¡d¡ d S )Núexit 0zexit 42Únté*   )r   r   r	   ÚcloseÚnameÚwaitstatus_to_exitcode)r   Ústatusr   r   r   Útest_return_code-   s
    
zPopenTest.test_return_codec                 C   s>   t  d¡ }|  | ¡ d¡ W d   ƒ n1 s00    Y  d S ©Nz
echo hellozhello
)r   r	   r   r
   ©r   Úfr   r   r   Útest_contextmanager5   s    zPopenTest.test_contextmanagerc                 C   s@   t  d¡"}|  t|ƒdg¡ W d   ƒ n1 s20    Y  d S r"   )r   r	   r   Úlistr#   r   r   r   Útest_iterating9   s    zPopenTest.test_iteratingc                 C   s4   t jdddd W d   ƒ n1 s&0    Y  d S )Nr   Úwéÿÿÿÿ)r   ÚmodeÚ	buffering)r   r	   r   r   r   r   Útest_keywords=   s    zPopenTest.test_keywordsN)	Ú__name__Ú
__module__Ú__qualname__r   r   r!   r%   r'   r,   r   r   r   r   r      s   r   Ú__main__)ZunittestÚtestr   r   ÚsysÚ
executabler   ZTestCaser   r-   Úmainr   r   r   r   Ú<module>   s   .