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

148 lines
5.5 KiB
Python

"""
High-value pure logic tests for benchmarks/runners.py.
Focuses on format_query() and other pure logic elements.
"""
from local_deep_research.benchmarks.runners import format_query
from local_deep_research.benchmarks.templates import BROWSECOMP_QUERY_TEMPLATE
class TestFormatQuerySimpleQA:
"""Tests for format_query with simpleqa dataset type."""
def test_simpleqa_returns_question_unchanged(self):
question = "What is the capital of France?"
result = format_query(question, "simpleqa")
assert result == question
def test_simpleqa_preserves_whitespace(self):
question = " leading and trailing spaces "
result = format_query(question, "simpleqa")
assert result == question
def test_simpleqa_empty_string(self):
result = format_query("", "simpleqa")
assert result == ""
def test_simpleqa_multiline_question(self):
question = "Line one\nLine two\nLine three"
result = format_query(question, "simpleqa")
assert result == question
def test_simpleqa_is_default_dataset_type(self):
question = "What year was Python created?"
result = format_query(question)
assert result == question
class TestFormatQueryBrowseComp:
"""Tests for format_query with browsecomp dataset type."""
def test_browsecomp_applies_template(self):
question = "Find the author of this article."
result = format_query(question, "browsecomp")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_browsecomp_case_insensitive_lowercase(self):
question = "Some question"
result = format_query(question, "browsecomp")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_browsecomp_case_insensitive_uppercase(self):
question = "Some question"
result = format_query(question, "BROWSECOMP")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_browsecomp_case_insensitive_mixed(self):
question = "Some question"
result = format_query(question, "BrowseComp")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_browsecomp_case_insensitive_random_casing(self):
question = "Some question"
result = format_query(question, "bRoWsEcOmP")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_browsecomp_empty_question(self):
result = format_query("", "browsecomp")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question="")
assert result == expected
def test_browsecomp_result_contains_question_text(self):
question = "Who wrote the first web browser?"
result = format_query(question, "browsecomp")
assert question in result
def test_browsecomp_result_contains_format_instructions(self):
question = "Test question"
result = format_query(question, "browsecomp")
assert "Exact Answer:" in result
assert "Confidence:" in result
assert "Explanation:" in result
def test_browsecomp_result_differs_from_raw_question(self):
question = "A simple question?"
result = format_query(question, "browsecomp")
assert result != question
assert len(result) > len(question)
class TestFormatQueryUnknownDatasetTypes:
"""Tests for format_query with unknown/other dataset types."""
def test_unknown_type_returns_question_unchanged(self):
question = "What is 2+2?"
result = format_query(question, "unknown_dataset")
assert result == question
def test_xbench_deepsearch_returns_question_unchanged(self):
question = "Complex research question"
result = format_query(question, "xbench_deepsearch")
assert result == question
def test_empty_dataset_type_returns_question_unchanged(self):
"""Empty string dataset type is not 'browsecomp', so returns unchanged."""
question = "Some question"
result = format_query(question, "")
assert result == question
def test_browsecomp_prefix_does_not_match(self):
"""Only exact match (case-insensitive) should trigger template."""
question = "Some question"
result = format_query(question, "browsecomp_v2")
assert result == question
def test_browsecomp_with_extra_spaces_does_not_match(self):
question = "Some question"
result = format_query(question, " browsecomp ")
assert result == question
class TestFormatQuerySpecialCharacters:
"""Tests for format_query with special characters in questions."""
def test_question_with_curly_braces(self):
"""Curly braces in question should not break template formatting."""
question = "What is {x} in the equation?"
# For simpleqa, returned as-is
result = format_query(question, "simpleqa")
assert result == question
def test_browsecomp_question_with_unicode(self):
question = "Qu'est-ce que c'est? Aeoeue"
result = format_query(question, "browsecomp")
expected = BROWSECOMP_QUERY_TEMPLATE.format(question=question)
assert result == expected
def test_question_with_newlines_browsecomp(self):
question = "First part\nSecond part"
result = format_query(question, "browsecomp")
assert "First part\nSecond part" in result
assert "Exact Answer:" in result