Skip to content

Commit ab9d0b3

Browse files
authored
Merge pull request #95 from G-Research/fix-tests
Make the tests pass more consistently
2 parents 58545e9 + c4265c4 commit ab9d0b3

File tree

190 files changed

+12
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+12
-15
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ahocorasick_rs"
3-
version = "0.20.0"
3+
version = "0.21.1"
44
edition = "2021"
55
authors = ["G-Research <[email protected]>", "Itamar Turner-Trauring <[email protected]>"]
66
description = "Search a string for multiple substrings at once"

tests/test_ac.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from hypothesis import strategies as st
10-
from hypothesis import given, assume
10+
from hypothesis import given
1111

1212
from ahocorasick_rs import (
1313
AhoCorasick,
@@ -140,19 +140,18 @@ def test_unicode_extensive(
140140
Non-ASCII unicode patterns still give correct results for
141141
find_matches_as_indexes(), with property-testing.
142142
"""
143-
assume(pattern not in prefix)
144-
assume(pattern not in suffix)
145143
haystack = prefix + pattern + suffix
146144
if store_patterns is None:
147145
ac = AhoCorasick([pattern])
148146
else:
149147
ac = AhoCorasick([pattern], store_patterns=store_patterns)
150148

151149
index_matches = ac.find_matches_as_indexes(haystack)
152-
expected = [pattern]
153-
assert [i for (i, _, _) in index_matches] == [0]
154-
assert [haystack[s:e] for (_, s, e) in index_matches] == expected
155-
assert ac.find_matches_as_strings(haystack) == [pattern]
150+
expected = {pattern}
151+
assert {i for (i, _, _) in index_matches} == {0}
152+
# Occasionally might get an overlap between haystack and preffix/suffix...
153+
assert {haystack[s:e] for (_, s, e) in index_matches} == expected
154+
assert set(ac.find_matches_as_strings(haystack)) == expected
156155

157156

158157
@pytest.mark.parametrize("bad_patterns", [[""], ["", "xx"], ["xx", ""]])

tests/test_ac_bytes.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from hypothesis import strategies as st
10-
from hypothesis import given, assume
10+
from hypothesis import given
1111

1212
from ahocorasick_rs import (
1313
BytesAhoCorasick,
@@ -123,15 +123,13 @@ def test_random_bytes_extensive(prefix: bytes, pattern: bytes, suffix: bytes) ->
123123
Random bytes patterns still give correct results for
124124
find_matches_as_indexes(), with property-testing.
125125
"""
126-
assume(pattern not in prefix)
127-
assume(pattern not in suffix)
128126
haystack = prefix + pattern + suffix
129127
ac = BytesAhoCorasick([pattern])
130128

131129
index_matches = ac.find_matches_as_indexes(haystack)
132-
expected = [pattern]
133-
assert [i for (i, _, _) in index_matches] == [0]
134-
assert [haystack[s:e] for (_, s, e) in index_matches] == expected
130+
assert {i for (i, _, _) in index_matches} == {0}
131+
# Occasionally might get overlap between haystack and prefix/suffix...
132+
assert {haystack[s:e] for (_, s, e) in index_matches} == {pattern}
135133

136134

137135
@pytest.mark.parametrize("bad_patterns", [[b""], [b"", b"xx"], [b"xx", b""]])

0 commit comments

Comments
 (0)