o
    HXîhO  ã                   @   s€   d Z ddlZddlmZ ddlZddlZeedƒse d¡‚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 dS )zQBasic tests for os.popen()

  Particularly useful for platforms that fake popen.
é    N)ÚsupportÚpopenzneed os.popen()ú ú"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 sw   Y  t|ƒdd … }|  ||¡ d S )Nz&%s -c "import sys; print(sys.argv)" %sé   )ÚpythonÚosr   ÚreadÚevalÚassertEqual)ÚselfZcmdlineZexpectedÚcmdÚpÚdataZgot© r   ú9/opt/python-3.10.19/usr/lib/python3.10/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   sT   |   t d¡ ¡ d ¡ t d¡ ¡ }tjdkr|   |d¡ d S |   t |¡d¡ d S )Núexit 0zexit 42Únté*   )r   r	   r   ÚcloseÚnameÚwaitstatus_to_exitcode)r   Ústatusr   r   r   Útest_return_code0   s
   
zPopenTest.test_return_codec                 C   s@   t  d¡}|  | ¡ d¡ W d   ƒ d S 1 sw   Y  d S ©Nz
echo hellozhello
)r	   r   r   r
   ©r   Úfr   r   r   Útest_contextmanager8   s   "ÿzPopenTest.test_contextmanagerc                 C   sB   t  d¡}|  t|ƒdg¡ W d   ƒ d S 1 sw   Y  d S r"   )r	   r   r   Úlistr#   r   r   r   Útest_iterating<   s   "ÿzPopenTest.test_iteratingc                 C   s6   t jdddd	 W d   ƒ d S 1 sw   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__)Ú__doc__ZunittestÚtestr   r	   ÚsysÚhasattrZSkipTestÚ
executabler   ZTestCaser   r-   Úmainr   r   r   r   Ú<module>   s    

.ÿ