test_ocr_filter.py 612 B

123456789101112131415161718192021
  1. from types import SimpleNamespace
  2. from module.ocr.base_ocr import BaseCor
  3. def boxed_text(text: str):
  4. return SimpleNamespace(ocr_text=text)
  5. def test_exact_filter_does_not_match_a_partial_nickname():
  6. target = object.__new__(BaseCor)
  7. results = [boxed_text('赈早见琥珀主'), boxed_text('龙鸣蚀心')]
  8. assert target.filter(results, '你的心', exact=True) is None
  9. def test_exact_filter_matches_the_complete_nickname():
  10. target = object.__new__(BaseCor)
  11. results = [boxed_text('轻芋'), boxed_text('你的心')]
  12. assert target.filter(results, '你的心', exact=True) == [1]