Skip to content

Commit f2b4b12

Browse files
committed
test: move empty-input tests into the existing evaluator test files
1 parent c6687d4 commit f2b4b12

5 files changed

Lines changed: 36 additions & 30 deletions

File tree

test/components/evaluators/test_answer_exact_match.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,12 @@ def test_run_with_different_lengths():
7171

7272
with pytest.raises(ValueError):
7373
evaluator.run(ground_truth_answers=["Berlin", "Paris"], predicted_answers=["Berlin"])
74+
75+
76+
def test_run_with_empty_inputs():
77+
evaluator = AnswerExactMatchEvaluator()
78+
79+
# Empty (equal-length) inputs previously fell through the length check and
80+
# crashed with a bare ZeroDivisionError when averaging over zero items.
81+
with pytest.raises(ValueError, match="must be provided"):
82+
evaluator.run(ground_truth_answers=[], predicted_answers=[])

test/components/evaluators/test_document_map.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,12 @@ def test_run_with_different_lengths():
147147
ground_truth_documents=[[Document(content="Berlin")], [Document(content="Paris")]],
148148
retrieved_documents=[[Document(content="Berlin")]],
149149
)
150+
151+
152+
def test_run_with_empty_inputs():
153+
evaluator = DocumentMAPEvaluator()
154+
155+
# Empty (equal-length) inputs previously fell through the length check and
156+
# crashed with a bare ZeroDivisionError when averaging over zero items.
157+
with pytest.raises(ValueError, match="must be provided"):
158+
evaluator.run(ground_truth_documents=[], retrieved_documents=[])

test/components/evaluators/test_document_mrr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,12 @@ def test_run_with_different_lengths():
150150
ground_truth_documents=[[Document(content="Berlin")], [Document(content="Paris")]],
151151
retrieved_documents=[[Document(content="Berlin")]],
152152
)
153+
154+
155+
def test_run_with_empty_inputs():
156+
evaluator = DocumentMRREvaluator()
157+
158+
# Empty (equal-length) inputs previously fell through the length check and
159+
# crashed with a bare ZeroDivisionError when averaging over zero items.
160+
with pytest.raises(ValueError, match="must be provided"):
161+
evaluator.run(ground_truth_documents=[], retrieved_documents=[])

test/components/evaluators/test_document_recall.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ def test_run_with_nested_meta_comparison():
6868
assert result == {"individual_scores": [0.5], "score": 0.5}
6969

7070

71+
def test_run_with_empty_inputs():
72+
evaluator = DocumentRecallEvaluator()
73+
74+
# Empty (equal-length) inputs previously fell through the length check and
75+
# crashed with a bare ZeroDivisionError when averaging over zero items.
76+
with pytest.raises(ValueError, match="must be provided"):
77+
evaluator.run(ground_truth_documents=[], retrieved_documents=[])
78+
79+
7180
class TestDocumentRecallEvaluatorSingleHit:
7281
@pytest.fixture
7382
def evaluator(self):

test/components/evaluators/test_evaluators_empty_input.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)