"""pytest 共享 fixture。""" from __future__ import annotations from pathlib import Path import pytest @pytest.fixture def sample_sources_yaml(tmp_path: Path) -> Path: """生成最小可用 sources.yaml 用于测试。""" content = """ settings: concurrency: 2 retry_max_attempts: 2 retry_min_wait_sec: 0.01 retry_max_wait_sec: 0.02 headless: true output_root: data/raw sources: - id: testsrc name: 测试源 enabled: true homepage: https://example.com/list article_url_pattern: '^https://example\\.com/article/\\d+$' js_render: false page_timeout_ms: 5000 max_articles_per_run: 5 """ p = tmp_path / "sources.yaml" p.write_text(content, encoding="utf-8") return p