Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

120 lines
4.8 KiB
Python

"""
Tests for benchmark evaluation templates.
This module tests the prompt templates used for evaluating model outputs
against reference answers.
"""
from local_deep_research.benchmarks.templates import (
BROWSECOMP_GRADER_TEMPLATE,
BROWSECOMP_QUERY_TEMPLATE,
SIMPLEQA_GRADER_TEMPLATE,
)
class TestSimpleQAGraderTemplate:
"""Tests for the SimpleQA grader template."""
def test_contains_question_placeholder(self):
"""Template must contain the question placeholder."""
assert "{question}" in SIMPLEQA_GRADER_TEMPLATE
def test_contains_correct_answer_placeholder(self):
"""Template must contain the correct_answer placeholder."""
assert "{correct_answer}" in SIMPLEQA_GRADER_TEMPLATE
def test_contains_response_placeholder(self):
"""Template must contain the response placeholder."""
assert "{response}" in SIMPLEQA_GRADER_TEMPLATE
def test_can_format_with_all_placeholders(self):
"""Template can be formatted with all required placeholders."""
formatted = SIMPLEQA_GRADER_TEMPLATE.format(
question="What is the capital of France?",
correct_answer="Paris",
response="The capital of France is Paris.",
)
assert "What is the capital of France?" in formatted
assert "Paris" in formatted
assert "The capital of France is Paris." in formatted
# Ensure no unformatted placeholders remain
assert "{question}" not in formatted
assert "{correct_answer}" not in formatted
assert "{response}" not in formatted
def test_contains_grading_instructions(self):
"""Template should contain instructions for grading."""
assert "Correct:" in SIMPLEQA_GRADER_TEMPLATE
assert "yes/no" in SIMPLEQA_GRADER_TEMPLATE
class TestBrowseCompGraderTemplate:
"""Tests for the BrowseComp grader template."""
def test_contains_question_placeholder(self):
"""Template must contain the question placeholder."""
assert "{question}" in BROWSECOMP_GRADER_TEMPLATE
def test_contains_correct_answer_placeholder(self):
"""Template must contain the correct_answer placeholder."""
assert "{correct_answer}" in BROWSECOMP_GRADER_TEMPLATE
def test_contains_response_placeholder(self):
"""Template must contain the response placeholder."""
assert "{response}" in BROWSECOMP_GRADER_TEMPLATE
def test_can_format_with_all_placeholders(self):
"""Template can be formatted with all required placeholders."""
formatted = BROWSECOMP_GRADER_TEMPLATE.format(
question="Who wrote Romeo and Juliet?",
correct_answer="William Shakespeare",
response="William Shakespeare wrote Romeo and Juliet.",
)
assert "Who wrote Romeo and Juliet?" in formatted
assert "William Shakespeare" in formatted
# Ensure no unformatted placeholders remain
assert "{question}" not in formatted
assert "{correct_answer}" not in formatted
assert "{response}" not in formatted
def test_contains_grading_fields(self):
"""Template should contain expected grading fields."""
assert "extracted_final_answer:" in BROWSECOMP_GRADER_TEMPLATE
assert "reasoning:" in BROWSECOMP_GRADER_TEMPLATE
assert "correct:" in BROWSECOMP_GRADER_TEMPLATE
assert "confidence:" in BROWSECOMP_GRADER_TEMPLATE
class TestBrowseCompQueryTemplate:
"""Tests for the BrowseComp query template."""
def test_contains_question_placeholder(self):
"""Template must contain the question placeholder."""
assert "{question}" in BROWSECOMP_QUERY_TEMPLATE
def test_can_format_with_question(self):
"""Template can be formatted with a question."""
formatted = BROWSECOMP_QUERY_TEMPLATE.format(
question="What year was the Eiffel Tower built?"
)
assert "What year was the Eiffel Tower built?" in formatted
assert "{question}" not in formatted
def test_contains_expected_response_format(self):
"""Template should specify the expected response format."""
assert "Explanation:" in BROWSECOMP_QUERY_TEMPLATE
assert "Exact Answer:" in BROWSECOMP_QUERY_TEMPLATE
assert "Confidence:" in BROWSECOMP_QUERY_TEMPLATE
def test_uses_escaped_braces_for_format_instructions(self):
"""Template uses escaped braces for format instructions that should remain literal."""
# The template uses {{ and }} for literal braces in format instructions
# After formatting, these should become { and }
formatted = BROWSECOMP_QUERY_TEMPLATE.format(question="Test question")
assert "{your explanation" in formatted
assert "{your succinct" in formatted
assert "{your confidence" in formatted