7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
113 lines
4.8 KiB
Python
113 lines
4.8 KiB
Python
"""Additional edge case tests for benchmarks/graders.py.
|
|
|
|
Focuses on extract_answer_from_response edge cases and citation
|
|
stripping that are not covered by the existing test suite.
|
|
"""
|
|
|
|
from local_deep_research.benchmarks.graders import extract_answer_from_response
|
|
|
|
|
|
class TestCitationStripping:
|
|
"""Tests for citation removal from responses."""
|
|
|
|
def test_adjacent_citations_all_removed(self):
|
|
result = extract_answer_from_response(
|
|
"Answer[1][2][3] here.", "simpleqa"
|
|
)
|
|
assert "[1]" not in result["extracted_answer"]
|
|
assert "[2]" not in result["extracted_answer"]
|
|
assert "[3]" not in result["extracted_answer"]
|
|
|
|
def test_high_numbered_citation_removed(self):
|
|
result = extract_answer_from_response(
|
|
"Fact [99] and [100].", "simpleqa"
|
|
)
|
|
assert "[99]" not in result["extracted_answer"]
|
|
assert "[100]" not in result["extracted_answer"]
|
|
|
|
def test_non_numeric_brackets_preserved(self):
|
|
result = extract_answer_from_response(
|
|
"Use [option A] for best results.", "simpleqa"
|
|
)
|
|
assert "[option A]" in result["extracted_answer"]
|
|
|
|
def test_citations_removed_before_browsecomp_extraction(self):
|
|
response = "Exact Answer: The result [1] is Paris [2]\nConfidence: 90%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert "[1]" not in result["extracted_answer"]
|
|
assert "[2]" not in result["extracted_answer"]
|
|
assert "Paris" in result["extracted_answer"]
|
|
|
|
|
|
class TestBrowseCompEdgeCases:
|
|
"""Edge cases for BrowseComp extraction."""
|
|
|
|
def test_exact_answer_with_colon_in_value(self):
|
|
response = "Exact Answer: Time: 12:30 PM\nConfidence: 85%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert "12:30" in result["extracted_answer"]
|
|
|
|
def test_exact_answer_with_numbers(self):
|
|
response = "Exact Answer: 3.14159\nConfidence: 100%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert result["extracted_answer"] == "3.14159"
|
|
|
|
def test_confidence_with_leading_zeros(self):
|
|
response = "Exact Answer: test\nConfidence: 05%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert result["confidence"] == "05"
|
|
|
|
def test_exact_answer_whitespace_stripped(self):
|
|
response = "Exact Answer: Paris \nConfidence: 80%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert result["extracted_answer"] == "Paris"
|
|
|
|
def test_multiple_exact_answer_lines_first_wins(self):
|
|
response = "Exact Answer: First\nExact Answer: Second\nConfidence: 70%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert result["extracted_answer"] == "First"
|
|
|
|
def test_answer_with_parentheses(self):
|
|
response = "Exact Answer: Albert Einstein (1879-1955)\nConfidence: 95%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert "Albert Einstein" in result["extracted_answer"]
|
|
assert "(1879-1955)" in result["extracted_answer"]
|
|
|
|
def test_answer_with_comma(self):
|
|
response = "Exact Answer: New York, United States\nConfidence: 90%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert "New York, United States" == result["extracted_answer"]
|
|
|
|
def test_empty_exact_answer_captures_next_line(self):
|
|
# When answer is empty, greedy \s* in regex consumes the newline,
|
|
# so (.*?) ends up matching the next line content.
|
|
response = "Exact Answer: \nConfidence: 50%"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
# This is the actual regex behavior — not ideal but matches implementation
|
|
assert result["extracted_answer"] == "Confidence: 50%"
|
|
|
|
def test_only_newline_after_answer(self):
|
|
response = "Exact Answer: Tokyo"
|
|
result = extract_answer_from_response(response, "browsecomp")
|
|
assert result["extracted_answer"] == "Tokyo"
|
|
|
|
|
|
class TestSimpleQAEdgeCases:
|
|
"""Edge cases for SimpleQA extraction."""
|
|
|
|
def test_multiline_response_preserved(self):
|
|
response = "Line 1\nLine 2\nLine 3"
|
|
result = extract_answer_from_response(response, "simpleqa")
|
|
assert "Line 1" in result["extracted_answer"]
|
|
assert "Line 3" in result["extracted_answer"]
|
|
|
|
def test_unicode_response_preserved(self):
|
|
response = "La réponse est: café"
|
|
result = extract_answer_from_response(response, "simpleqa")
|
|
assert "café" in result["extracted_answer"]
|
|
|
|
def test_response_with_only_citations(self):
|
|
result = extract_answer_from_response("[1][2][3]", "simpleqa")
|
|
# All citations removed, should be empty-ish
|
|
assert "[" not in result["extracted_answer"]
|