ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Trailing commas in page_range must not crash parse_page_range."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
_SRC = Path(__file__).resolve().parent / "src" / "document_processing_tools.py"
|
||||
_spec = importlib.util.spec_from_file_location("document_processing_tools_page_range", _SRC)
|
||||
_mod = importlib.util.module_from_spec(_spec)
|
||||
# Load only parse_page_range without heavy optional deps (PyPDF2, etc.).
|
||||
source = _SRC.read_text(encoding="utf-8")
|
||||
start = source.index("def parse_page_range")
|
||||
ns = {}
|
||||
exec(compile(source[start:], str(_SRC), "exec"), ns)
|
||||
parse_page_range = ns["parse_page_range"]
|
||||
|
||||
|
||||
def test_trailing_comma_does_not_raise():
|
||||
assert parse_page_range("1,3,", 10) == [0, 2]
|
||||
|
||||
|
||||
def test_duplicate_comma_does_not_raise():
|
||||
assert parse_page_range("1,,3", 10) == [0, 2]
|
||||
|
||||
|
||||
def test_leading_comma_does_not_raise():
|
||||
assert parse_page_range(",1,5", 10) == [0, 4]
|
||||
|
||||
|
||||
def test_normal_list_unchanged():
|
||||
assert parse_page_range("1,3,5", 10) == [0, 2, 4]
|
||||
|
||||
|
||||
def test_range_with_trailing_comma():
|
||||
assert parse_page_range("1-3,", 10) == [0, 1, 2]
|
||||
Reference in New Issue
Block a user