Skip to content

Commit

Permalink
Ensure byte tests use bytes
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 0995f28 commit f380d62
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/test_issue_133.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@
"""
import ahocorasick

from pytestingutils import conv


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

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

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


def test_issue133_2():
automaton = ahocorasick.Automaton()
for word in ["b", "c", "abd"]:
automaton.add_word(word, word)
converted = conv(word)
automaton.add_word(converted, word)
automaton.make_automaton()

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

expected = [(1, "b"), (2, "c")]
assert res == expected
Expand All @@ -37,10 +40,11 @@ def test_issue133_2():
def test_issue133_3():
automaton = ahocorasick.Automaton()
for word in ["知识产权", "国家知识产权局"]:
automaton.add_word(word, word)
converted = conv(word)
automaton.add_word(converted, word)
automaton.make_automaton()

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

expected = [(5, "知识产权")]
assert res == expected

0 comments on commit f380d62

Please sign in to comment.