Ë
    Ï�Dj  ã                   ó–  — 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         €úRC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\joblib/testing.pyÚshowwarningz'warnings_to_stdout.<locals>.showwarning    s&   ø€ Ù˜˜c¤2§7¡7×#3Ñ#3°EÓ#:¸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_process4   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_process=   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¬
¯©Ü#-§?¡?ô4€Dõõð ØÐÜ'Ÿo™o¨gÐ7HÓIˆOØ×!Ñ!Ô#Ü"Ÿ™¨¨W©°lÓCˆJØ×ÑÔØ×)Ñ)Ó+‰ˆ�ØŸ™›¨&¯-©-«/�ˆØ�?‰?˜aÒðß%™vØ—O‘O V¨Vó 5ð ô ˜WÓ%Ð%àÐ$Ü—I‘I˜l¨FÔ3ÜØ?×FÑFØ  &ó*ó+ð +ð Ð$Ü—I‘I˜l¨FÔ3ÜØ?×FÑFØ  &ó*ó+ð +ð
 ÐØ×"Ñ"Ô$Ø×ÑÕð øˆ7ÐØ×"Ñ"Ô$Ø×ÑÕð ús   ÁD!F	 Æ	%F.)é   NN)Ú__doc__r   r   Úos.pathr   r/   r$   r'   ÚpytestÚ_pytestÚraisesÚwarnsÚrunnerÚSkippedÚSkipTestÚmarkÚskipifÚfixtureÚparametrizer2   ÚxfailÚparamr   r8   © r   r   ú<module>rJ      s§   ðñó Û Û Û 	Û Û ã Û ð 
�‰€Ø�‰€Ø�>‰>×!Ñ!€Ø	�‰×	Ñ	€Ø
�.‰.€Ø�k‰k×%Ñ%€Ø
�+‰+×
Ñ
€Ø�‰×Ñ€Ø�‰€ò'ð 8<Ø'+ô< r   