项目文件夹

文件
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

157 行
5.2 KiB
Python

"""
Coverage tests for benchmarks/datasets/simpleqa.py.
Targets the 12 missing lines:
- get_dataset_info()
- get_default_dataset_path()
- process_example() – normal, missing problem, missing answer, missing correct_answer
- get_question()
- get_answer()
"""
from unittest.mock import patch
MODULE = "local_deep_research.benchmarks.datasets.simpleqa"
def _make_dataset(**kwargs):
from local_deep_research.benchmarks.datasets.simpleqa import SimpleQADataset
return SimpleQADataset(**kwargs)
# ---------------------------------------------------------------------------
# Dataset metadata
# ---------------------------------------------------------------------------
class TestSimpleQADatasetInfo:
def test_get_dataset_info_has_simpleqa_id(self):
from local_deep_research.benchmarks.datasets.simpleqa import (
SimpleQADataset,
)
info = SimpleQADataset.get_dataset_info()
assert info["id"] == "simpleqa"
def test_get_dataset_info_has_all_required_keys(self):
from local_deep_research.benchmarks.datasets.simpleqa import (
SimpleQADataset,
)
info = SimpleQADataset.get_dataset_info()
assert "name" in info
assert "description" in info
assert "url" in info
def test_get_default_dataset_path_is_url(self):
from local_deep_research.benchmarks.datasets.simpleqa import (
SimpleQADataset,
)
path = SimpleQADataset.get_default_dataset_path()
assert path.startswith("https://")
assert "simple" in path.lower()
def test_dataset_info_url_matches_default_path(self):
from local_deep_research.benchmarks.datasets.simpleqa import (
SimpleQADataset,
)
info = SimpleQADataset.get_dataset_info()
assert info["url"] == SimpleQADataset.get_default_dataset_path()
def test_default_path_ends_with_csv(self):
from local_deep_research.benchmarks.datasets.simpleqa import (
SimpleQADataset,
)
path = SimpleQADataset.get_default_dataset_path()
assert path.endswith(".csv")
# ---------------------------------------------------------------------------
# process_example – normal case
# ---------------------------------------------------------------------------
class TestSimpleQAProcessExampleNormal:
def test_process_example_preserves_problem_and_answer(self):
ds = _make_dataset()
example = {"problem": "What is 2+2?", "answer": "4"}
result = ds.process_example(example)
assert result["problem"] == "What is 2+2?"
assert result["answer"] == "4"
def test_process_example_adds_correct_answer(self):
ds = _make_dataset()
example = {"problem": "Q", "answer": "A"}
result = ds.process_example(example)
assert result["correct_answer"] == "A"
def test_process_example_preserves_existing_correct_answer(self):
ds = _make_dataset()
example = {"problem": "Q", "answer": "A", "correct_answer": "CA"}
result = ds.process_example(example)
assert result["correct_answer"] == "CA"
def test_process_example_does_not_mutate_original(self):
ds = _make_dataset()
original = {"problem": "Q", "answer": "A"}
ds.process_example(original)
assert "correct_answer" not in original
# ---------------------------------------------------------------------------
# process_example – missing fields
# ---------------------------------------------------------------------------
class TestSimpleQAProcessExampleMissingFields:
def test_missing_problem_added_as_empty_string(self):
ds = _make_dataset()
result = ds.process_example({"answer": "A"})
assert result["problem"] == ""
def test_missing_problem_logs_warning(self):
ds = _make_dataset()
with patch(f"{MODULE}.logger") as mock_logger:
ds.process_example({"answer": "A"})
mock_logger.warning.assert_called_once()
def test_missing_answer_added_as_empty_string(self):
ds = _make_dataset()
result = ds.process_example({"problem": "P"})
assert result["answer"] == ""
def test_missing_answer_logs_warning(self):
ds = _make_dataset()
with patch(f"{MODULE}.logger") as mock_logger:
ds.process_example({"problem": "P"})
mock_logger.warning.assert_called_once()
# ---------------------------------------------------------------------------
# get_question / get_answer
# ---------------------------------------------------------------------------
class TestSimpleQAGetQuestionAndAnswer:
def test_get_question_returns_problem(self):
ds = _make_dataset()
example = {"problem": "Capital of Germany?", "answer": "Berlin"}
assert ds.get_question(example) == "Capital of Germany?"
def test_get_question_returns_empty_when_missing(self):
ds = _make_dataset()
assert ds.get_question({}) == ""
def test_get_answer_returns_answer_field(self):
ds = _make_dataset()
example = {"answer": "Berlin"}
assert ds.get_answer(example) == "Berlin"
def test_get_answer_returns_empty_when_missing(self):
ds = _make_dataset()
assert ds.get_answer({}) == ""