o
    l¨Êhœ  ã                   @   sœ   d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ejZejZe	jjZejjZejZejjZejjZdd„ Z		d	dd„ZdS )
z
Helper for testing.
é    N)ÚPY3_OR_LATERc                     s   t j‰ d‡ fdd„	} | t _dS )z& Redirect all warnings to stdout.
    Nr   c                    s   ˆ | |t j |¡|tjƒ d S )N)ÚosÚpathÚbasenameÚsysÚstdout)ÚmsgÚcatÚfnameÚlnoÚfileÚline©Úshowwarning_orig© ú@/var/www/html/env/lib/python3.10/site-packages/joblib/testing.pyÚshowwarning    s   z'warnings_to_stdout.<locals>.showwarning)Nr   )Úwarningsr   )r   r   r   r   Úwarnings_to_stdout   s   
r   é   c           	         sê   t jˆ t jt jd�‰‡ ‡fdd„}t ||¡}zX| ¡  ˆ ¡ \}}tr-| ¡ | ¡ }}ˆj	dkr>d 
ˆj	||¡}t|ƒ‚|durPt ||¡sPtd 
||¡ƒ‚|durbt ||¡sitd 
||¡ƒ‚W | ¡  dS W | ¡  dS | ¡  w )	z§Runs a command in a subprocess with timeout in seconds.

    Also checks returncode is zero, stdout if stdout_regex is set, and
    stderr if stderr_regex is set.
    )r   Ústderrc                      s   t  d ˆ ¡¡ ˆ ¡  d S )NzTimeout running {})r   ÚwarnÚformatÚkillr   ©ÚcmdÚprocr   r   Úkill_process1   s   z+check_subprocess_call.<locals>.kill_processr   z/Non-zero return code: {}.
Stdout:
{}
Stderr:
{}Nz,Unexpected stdout: {!r} does not match:
{!r}z,Unexpected stderr: {!r} does not match:
{!r})Ú
subprocessÚPopenÚPIPEÚ	threadingÚTimerÚstartÚcommunicater   ÚdecodeÚ
returncoder   Ú
ValueErrorÚreÚsearchÚcancel)	r   ÚtimeoutÚstdout_regexÚstderr_regexr   Útimerr   r   Úmessager   r   r   Úcheck_subprocess_call'   sJ   
ÿ
ÿþ
ÿÿÿ
ÿÿÿþùr0   )r   NN)Ú__doc__r   r   Úos.pathr   r(   r   r!   ÚpytestÚ_pytestÚjoblib._compatr   ÚraisesÚwarnsÚrunnerÚSkippedÚSkipTestÚmarkÚskipifÚfixtureÚparametrizer+   r   r0   r   r   r   r   Ú<module>   s*    ÿ