From 616309a08b6cdef5324e8551df7eef40efdcd7cd Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 10 Jun 2026 07:25:16 +0800 Subject: [PATCH] test: fix rust accel unit expectations --- pytest.ini | 2 ++ tests/test_rust_accel.py | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pytest.ini b/pytest.ini index 811afe0a..f5b2d24a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,6 @@ [pytest] +testpaths = + tests # 仅对「无法在本仓修复根因」的已知上游/三方弃用告警做精确忽略,保持测试输出干净、 # 让本仓自身的新告警更醒目。本仓代码引发的告警一律不在此忽略,应在源码/用例处修复。 filterwarnings = diff --git a/tests/test_rust_accel.py b/tests/test_rust_accel.py index 4c6774ab..654b53ef 100644 --- a/tests/test_rust_accel.py +++ b/tests/test_rust_accel.py @@ -521,21 +521,32 @@ def test_rust_subtitle_parser_is_several_times_faster_than_python(monkeypatch): ) -def test_rust_indexer_parser_handles_default_values_and_template_arithmetic(): +def test_rust_indexer_parser_handles_title_template_fallback_and_links(): """ - Rust indexer 解析应支持 defualt_value、Jinja int filter 和模板算术表达式。 + Rust indexer 解析应支持标题模板兜底并补全详情与下载链接。 """ html = """ - +
Default.Title + Default.Title + DL +
""" fields = { "title_default": {"selector": 'a[href*="details.php?id="]'}, - "missing_days": {"defualt_value": "2", "selector": "span.missing"}, - "title": {"text": "{{ fields['title_default'] }} {{ (fields['missing_days']|int)*86400 }}"}, + "title_optional": { + "selector": 'a[title][href*="details.php?id="]', + "attribute": "title", + }, + "title": { + "text": "{% if fields['title_optional'] %}{{ fields['title_optional'] }}{% else %}" + "{{ fields['title_default'] }}{% endif %}" + }, + "details": {"selector": 'a[href*="details.php?id="]', "attribute": "href"}, + "download": {"selector": 'a[href*="download.php?id="]', "attribute": "href"}, } result = rust_accel.parse_indexer_torrents( @@ -547,7 +558,11 @@ def test_rust_indexer_parser_handles_default_values_and_template_arithmetic(): result_num=100, ) - assert result == [{"title": "Default.Title 172800"}] + assert result == [{ + "page_url": "https://example.com/details.php?id=200", + "enclosure": "https://example.com/download.php?id=200", + "title": "Default.Title", + }] def test_rust_indexer_parser_handles_lstrip_and_english_elapsed_date():