Spaces:
Sleeping
Sleeping
File size: 746 Bytes
12d8080 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # test_local_model.py
from transformers import pipeline
def test_local_model_load():
"""
Test that the local sentiment model loads and returns valid output.
"""
model = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
result = model("I am happy!")[0]
# Assertions to make sure model output has expected keys
assert "label" in result, "Model output missing 'label'"
assert "score" in result, "Model output missing 'score'"
assert isinstance(result["score"], float), "'score' should be a float"
assert isinstance(result["label"], str), "'label' should be a string"
if __name__ == "__main__":
test_local_model_load()
print("✅ Local model test passed!")
|