insect-detection / tests /test_insectid.py
cabrel09's picture
Mise à jour de l'application
b0a8eab
Raw
History Blame Contribute Delete
942 Bytes
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