o
    l¨Êh£	  ã                   @   sL   d dl Z d dlZd dlmZmZ dd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dS )é    N)ÚraisesÚcheck_subprocess_callc                  C   s6   d  g d¢¡} ttjd| gƒ ttjd| gdd� d S )NÚ
)zresult = 1 + 2 * 3zprint(result)zmy_list = [1, 2, 3]zprint(my_list)ú-cz7\s{1,2}\[1, 2, 3\]©Ústdout_regex)Újoinr   ÚsysÚ
executable)Úcode© r   úJ/var/www/html/env/lib/python3.10/site-packages/joblib/test/test_testing.pyÚtest_check_subprocess_call   s
   
þr   c                  C   sX   d} d}t tƒ�}ttjd| g|d� W d   ƒ n1 sw   Y  | d |¡¡ d S )NÚ42Ú_no_way_this_matches_anything_r   r   zUnexpected stdout.+{})r   Ú
ValueErrorr   r	   r
   ÚmatchÚformat)r   Únon_matching_patternÚexcinfor   r   r   Ú-test_check_subprocess_call_non_matching_regex   s   
ÿÿr   c                  C   s<   d} t tƒ� t| gƒ W d   ƒ d S 1 sw   Y  d S )NÚ_a_command_that_does_not_exist_)r   ÚOSErrorr   )Úwrong_commandr   r   r   Ú(test_check_subprocess_call_wrong_command   s   
"ÿr   c                  C   sb   d  g d¢¡} t dtj¡}ttƒ�}ttjd| gƒ W d   ƒ n1 s%w   Y  | 	|¡ d S )Nr   )ú
import syszprint("writing on stdout")z%sys.stderr.write("writing on stderr")zsys.exit(123)zONon-zero return code: 123.+Stdout:
writing on stdout.+Stderr:
writing on stderrr   ©
r   ÚreÚcompileÚDOTALLr   r   r   r	   r
   r   )Úcode_with_non_zero_exitÚpatternr   r   r   r   Ú/test_check_subprocess_call_non_zero_return_code%   s   þ
ÿr"   c                  C   sf   d  g d¢¡} t dtj¡}ttƒ�}ttjd| gdd� W d   ƒ n1 s'w   Y  | 	|¡ d S )Nr   )	zimport timer   zprint("before sleep on stdout")úsys.stdout.flush()z*sys.stderr.write("before sleep on stderr")zsys.stderr.flush()ztime.sleep(1.1)z-print("process should have be killed before")r#   zVNon-zero return code:.+Stdout:
before sleep on stdout\s+Stderr:
before sleep on stderrr   é   )Útimeoutr   )Úcode_timing_outr!   r   r   r   r   Ú"test_check_subprocess_call_timeout5   s   ý
ÿÿr'   )
r	   r   Újoblib.testingr   r   r   r   r   r"   r'   r   r   r   r   Ú<module>   s    
