Files
BiliNote/backend/tests/test_screenshot_marker.py
CyanAutumn d9a7b89e7d 🐞 fix: 增加错误之后对已解析段落的缓存功能,再次重试时不再重头开始
解析长视频时,当附件大小过大时不再调用后进行报错,而是将附件进行分批次发送

在每篇笔记开头默认增加地址来源链接,对模糊处可溯源
2026-02-12 18:28:11 +08:00

36 lines
1.2 KiB
Python

import importlib.util
import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[1]
MODULE_PATH = ROOT / "app" / "utils" / "screenshot_marker.py"
spec = importlib.util.spec_from_file_location("screenshot_marker", MODULE_PATH)
if spec is None or spec.loader is None:
raise ImportError("screenshot_marker module spec not found")
screenshot_marker = importlib.util.module_from_spec(spec)
spec.loader.exec_module(screenshot_marker)
extract_screenshot_timestamps = screenshot_marker.extract_screenshot_timestamps
class TestScreenshotMarker(unittest.TestCase):
def test_extract_accepts_star_bracket_format(self):
markdown = "A\n*Screenshot-[01:02]\nB"
matches = extract_screenshot_timestamps(markdown)
self.assertEqual(matches, [("*Screenshot-[01:02]", 62)])
def test_extract_accepts_legacy_formats(self):
markdown = "*Screenshot-03:04 and Screenshot-[05:06]"
matches = extract_screenshot_timestamps(markdown)
self.assertEqual(
matches,
[
("*Screenshot-03:04", 184),
("Screenshot-[05:06]", 306),
],
)
if __name__ == "__main__":
unittest.main()