File size: 942 Bytes
b0a8eab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
import numpy as np
from insectid.base import OnnxModel, check_image_dtype_and_shape


def test_check_image_dtype_and_shape():
    # Test avec une image valide
    valid_image = np.random.randint(0, 255, (224, 224, 3)).astype(np.uint8)
    
    # Note: La fonction actuelle lève une exception pour uint8, ce qui peut être un bug
    # Mais nous testons son comportement actuel
    with pytest.raises(Exception):
        check_image_dtype_and_shape(valid_image)
    
    # Test avec float32
    float_image = valid_image.astype(np.float32)
    try:
        check_image_dtype_and_shape(float_image)
        # Si pas d'exception, le test réussit
        assert True
    except Exception as e:
        pytest.fail(f"check_image_dtype_and_shape raised {e} unexpectedly")


def test_onnx_model_init():
    # Note: Ce test nécessite un fichier ONNX réel. Pour l'instant, on vérifie juste l'import
    assert OnnxModel is not None