o
    /if                     @   s  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 d dlm	Z	 d dl
mZmZ d dlmZ d dlmZmZmZmZ d dl
mZ d dlmZ d d	lmZ ejd
dZdefddZe ddddddejdddddejdddddejdddddejdddddejdd d!d"dfded#ed$ed%ed&ed'eeed(d)f d*eeed+d,f d-e	e d.e	e d/e	e d0e	e d1e	e fd2d3Z dS )4    N)	Annotated)Optional)test_run_managerTEMP_FILE_NAME)TEMP_CACHE_FILE_NAME)delete_file_if_existsget_deployment_configsset_should_ignore_errorsset_should_use_cache)invoke_test_run_end_hook)capture_evaluation_run)set_is_running_deepevaltest)nametest_file_or_directoryc                 C   sf   d| v r|  d\} }tj| r'| dr#tj| ds%tdd S d S tj| r/d S td)Nz::z.pytest_zETest will not run. Please ensure the file starts with `test_` prefix.z6Provided path is neither a valid file nor a directory.)	splitospathisfileendswithbasename
startswith
ValueErrorisdir)r   	test_case r   J/var/www/html/corbot_env/lib/python3.10/site-packages/deepeval/cli/test.pycheck_if_valid_file   s   
r   Tyes
   Fz--num-processes-nz&Number of processes to use with pytest)helpz--repeatz-rz$Number of times to rerun a test casez--use-cachez-cz$Whether to use cached results or notz--ignore-errorsz-izWhether to ignore errors or notz--mark-mz$List of marks to run the tests with.verbosecolor	durationspdbexit_on_first_failurez--exit-on-first-failurez-x/-Xshow_warningsz--show-warningsz-w/-Wnum_processesrepeat	use_cacheignore_errorsmarkc                 C   s  t t t t t|  td |	o|du }t| t|
 t  | g}|r-|	dd t
 }|dur@t|}|d|g ||rFdndd| d	| d
g |rZ|d |sa|d |durn|dt|g |dur|dt|g |dk rtd|r|d|g |ddg t }td t|}W d   n1 sw   Y  t }|| }t| t  |dkrtd |S )z
Run a testTNr   z-xz--deploymentz	--verbosez--quietz--color=z--durations=z-sz--pdbz--disable-warningsr!   z--count   z'The repeat argument must be at least 1.r#   z-ppluginszdeepeval test run)r   r   r   r   r   r
   r	   r   resetinsertr   jsondumpsextendappendstrr   timeperf_counterr   pytestmainwrap_up_test_runr   sysexit)r   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   should_use_cachepytest_argsdeployment_configsdeployment_configs_json
start_timepytest_retcodeend_timerun_durationr   r   r   run*   s\   -

	




rG   )!r8   r:   typerr   r3   r=   typing_extensionsr   typingr   deepeval.test_runr   r   deepeval.test_run.cacher   deepeval.utilsr   r   r	   r
   r   deepeval.telemetryr   r   Typerappr7   r   commandOptionboolintrG   r   r   r   r   <module>   s    	$