a
    feza                     @   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	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ejjZejZdd ZdddZdS )	z
Helper for testing.
    Nc                     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Zshowwarning_orig -lib/python3.9/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||}z|   \}}| |  }}jdkrxd	j||}t
||durt||st
d	|||durt||st
d	||W |  n
|  0 dS )	zRuns 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startZcommunicatedecode
returncoder   
ValueErrorresearchcancel)	r   timeoutZstdout_regexZstderr_regexr   Ztimerr   r   messager   r   r   check_subprocess_call'   s@    



r*   )r   NN)__doc__r   r   Zos.pathr   r%   r   r   ZpytestZ_pytestZraisesZwarnsZrunnerZSkippedZSkipTestZmarkZskipifZfixtureZparametrizer(   ZxfailZparamr   r*   r   r   r   r   <module>   s*     