a
    yfg                     @   sD   d dl Z d dlmZ d dlmZ dd Zdd Zdd	 Zd
d ZdS )    N)Path)TMPc                 C   s   | j ddddd dS )z
    Add custom command-line options to pytest.

    Args:
        parser (pytest.config.Parser): The pytest parser object for adding custom command-line options.

    Returns:
        (None)
    --slow
store_trueFzRun slow tests)actiondefaulthelpN)Z	addoption)parser r
   J/var/www/html/django/DPS/env/lib/python3.9/site-packages/tests/conftest.pypytest_addoption	   s    
r   c                 C   s$   |  ds dd |D |dd< dS )a  
    Modify the list of test items to exclude tests marked as slow if the --slow option is not specified.

    Args:
        config (pytest.config.Config): The pytest configuration object that provides access to command-line options.
        items (list): The list of collected pytest item objects to be modified based on the presence of --slow option.

    Returns:
        (None) The function modifies the 'items' list in place, and does not return a value.
    r   c                 S   s   g | ]}d |j vr|qS )Zslow)keywords).0itemr
   r
   r   
<listcomp>#       z1pytest_collection_modifyitems.<locals>.<listcomp>N)Z	getoption)configitemsr
   r
   r   pytest_collection_modifyitems   s    
r   c                 C   s2   ddl m} |  tjtdd tjddd dS )a}  
    Initialize session configurations for pytest.

    This function is automatically called by pytest after the 'Session' object has been created but before performing
    test collection. It sets the initial seeds and prepares the temporary directory for the test session.

    Args:
        session (pytest.Session): The pytest session object.

    Returns:
        (None)
    r   )
init_seedsTignore_errors)parentsexist_okN)Zultralytics.utils.torch_utilsr   shutilrmtreer   mkdir)sessionr   r
   r
   r   pytest_sessionstart&   s    r   c                    s   ddl m   fdddD }g d| D ]}t|jdd q* fd	dd
D }tjd d tg| D ]}tj|dd qhdS )a  
    Cleanup operations after pytest session.

    This function is automatically called by pytest at the end of the entire test session. It removes certain files
    and directories used during testing.

    Args:
        terminalreporter (pytest.terminal.TerminalReporter): The terminal reporter object used for terminal output.
        exitstatus (int): The exit status of the test run.
        config (pytest.config.Config): The pytest config object.

    Returns:
        (None)
    r   WEIGHTS_DIRc                    s    g | ]}  |D ]}|qqS r
   rglobr   xpathr   r
   r   r   L   r   z+pytest_terminal_summary.<locals>.<listcomp>)z*.onnxz*.torchscript)zbus.jpgzyolo11n.onnxzyolo11n.torchscriptT)
missing_okc                    s    g | ]}  |D ]}|qqS r
   r!   r#   r   r
   r   r   Q   r   )z*.mlpackagez*_openvino_model   z.pytest_cacher   N)Zultralytics.utilsr    r   unlinkr   r   r   r   )ZterminalreporterZ
exitstatusr   modelsfile	directoryr
   r   r   pytest_terminal_summary:   s    r,   )	r   pathlibr   testsr   r   r   r   r,   r
   r
   r
   r   <module>   s   