
    e!h                        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 ZddZy)z
Helper for testing.
    Nc                  H    t         j                  dfd	} | t         _        y)z Redirect all warnings to stdout.Nc                 t     | |t         j                  j                  |      |t        j                         y )N)ospathbasenamesysstdout)msgcatfnamelnofilelineshowwarning_origs         V/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/joblib/testing.pyshowwarningz'warnings_to_stdout.<locals>.showwarning   s&    c277#3#3E#:D#**M    )Nr   )warningsr   )r   r   s    @r   warnings_to_stdoutr      s    ++N 'Hr   c                 b    t        j                   t         j                  t         j                         fd} fd}	 |Ot        j                  ||      }|j                          t        j                  d|z  |      }|j                          j                         \  }}	|j                         |	j                         }	}j                  dk7  r(dj                  j                  ||	      }
t        |
      |1t        j                  ||      st        dj                  ||            |1t        j                  ||	      st        d	j                  ||	            |!j                          j                          yy# |!j                          j                          w w xY w)
a  Runs a command in a subprocess with timeout in seconds.

    A SIGTERM is sent after `timeout` and if it does not terminate, a
    SIGKILL is sent after `2 * timeout`.

    Also checks returncode is zero, stdout if stdout_regex is set, and
    stderr if stderr_regex is set.
    )r	   stderrc                  V    t        j                  d         j                          y)z
        Attempt to terminate a leftover process spawned during test execution:
        ideally this should not be needed but can help avoid clogging the CI
        workers in case of deadlocks.
        Timeout running N)r   warn	terminatecmdprocs   r   terminate_processz0check_subprocess_call.<locals>.terminate_process0   s#     	(./r   c                  V    t        j                  d         j                          y)z
        Kill a leftover process spawned during test execution: ideally this
        should not be needed but can help avoid clogging the CI workers in
        case of deadlocks.
        r   N)r   r   killr   s   r   kill_processz+check_subprocess_call.<locals>.kill_process9   s"     	(./		r   N   r   z/Non-zero return code: {}.
Stdout:
{}
Stderr:
{}z,Unexpected stdout: {!r} does not match:
{!r}z,Unexpected stderr: {!r} does not match:
{!r})
subprocessPopenPIPE	threadingTimerstartcommunicatedecode
returncodeformat
ValueErrorresearchcancel)r   timeoutstdout_regexstderr_regexr   r"   terminate_timer
kill_timerr	   r   messager   s   `          @r   check_subprocess_callr8   %   s    C

PD 'oog7HIO!!#"WlCJ))+&--/??aLTTG W%%#BIIlF,K?FF & 
 #BIIlF,K?FF &  ""$ 7""$ s   D!F	 	%F.)   NN)__doc__os.pathr   r/   r$   r   r'   r   _pytestpytestraiseswarnsrunnerSkippedSkipTestmarkskipiffixtureparametrizer2   xfailparamr   r8    r   r   <module>rJ      s     	  
    	>>!!			
..kk%%
++

'; r   