Skip to content

Commit

Permalink
Adjust expectations for bytes automaton tests
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Jan 14, 2023
1 parent f380d62 commit c98e999
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/test_issue_133.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
from pytestingutils import conv


def test_issue133():
def test_issue133_iter_long_1():
automaton = ahocorasick.Automaton()
automaton.add_word(conv("b"), "b")
automaton.add_word(conv("abc"), "abc")
automaton.make_automaton()

res = list(automaton.iter_long(conv("abb")))

expected = [(1, conv("b")), (2, conv("b"))]
expected = [(1, "b"), (2, "b")]
assert res == expected


def test_issue133_2():
def test_issue133_iter_long_2():
automaton = ahocorasick.Automaton()
for word in ["b", "c", "abd"]:
converted = conv(word)
Expand All @@ -37,14 +37,17 @@ def test_issue133_2():
assert res == expected


def test_issue133_3():
def test_issue133_iter_long_with_multibyte_characters():
automaton = ahocorasick.Automaton()
for word in ["知识产权", "国家知识产权局"]:
converted = conv(word)
automaton.add_word(converted, word)
automaton.make_automaton()

res = list(automaton.iter_long(conv("国家知识产权")))

expected = [(5, "知识产权")]
if ahocorasick.unicode:
expected = [(5, "知识产权")]
else:
# UTF-8-bytes
expected = [(17, "知识产权")]
assert res == expected

0 comments on commit c98e999

Please sign in to comment.