From 0cca86eb411162ac12b08e8fd78f8f5f2a80e016 Mon Sep 17 00:00:00 2001 From: c4f3a0ce <30480807+c4f3a0ce@users.noreply.github.com> Date: Sun, 8 Dec 2019 11:53:32 +0100 Subject: [PATCH 1/3] Update libdatatrie to 6ef4485474890606946ed208ff453231b581cdf1 and provide tests for #74 This resolves #74 --- libdatrie | 2 +- tests/test_trie.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libdatrie b/libdatrie index d1dfdb8..6ef4485 160000 --- a/libdatrie +++ b/libdatrie @@ -1 +1 @@ -Subproject commit d1dfdb831093892541cae46eba82c46aec94f726 +Subproject commit 6ef4485474890606946ed208ff453231b581cdf1 diff --git a/tests/test_trie.py b/tests/test_trie.py index 492e524..c664304 100644 --- a/tests/test_trie.py +++ b/tests/test_trie.py @@ -423,3 +423,21 @@ def test_trie_fuzzy(): for index, word in enumerated_words: assert word in trie, word assert trie[word] == index, (word, index) + +def test_trie_handles_long_alphabets(): + # https://github.com/pytries/datrie/issues/74 + + import hypothesis.strategies as st + from hypothesis import given + + alphabet = [chr(i) for i in range(1500)] + @given(st.lists(st.text(alphabet))) + def _(xs): + trie = datrie.Trie(alphabet) + for x in xs: + trie[x] = True + + for x in xs: + assert x in trie + + _() From 3b09cbbfcec4c8b2aefdd00fac426e21b2a9db87 Mon Sep 17 00:00:00 2001 From: c4f3a0ce <30480807+c4f3a0ce@users.noreply.github.com> Date: Sun, 8 Dec 2019 13:04:51 +0100 Subject: [PATCH 2/3] Skip test if Python 2 --- tests/test_trie.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/test_trie.py b/tests/test_trie.py index c664304..f9ce379 100644 --- a/tests/test_trie.py +++ b/tests/test_trie.py @@ -427,17 +427,20 @@ def test_trie_fuzzy(): def test_trie_handles_long_alphabets(): # https://github.com/pytries/datrie/issues/74 + import sys import hypothesis.strategies as st from hypothesis import given - alphabet = [chr(i) for i in range(1500)] - @given(st.lists(st.text(alphabet))) - def _(xs): - trie = datrie.Trie(alphabet) - for x in xs: - trie[x] = True + if sys.version_info > (2, ): - for x in xs: - assert x in trie + alphabet = [chr(i) for i in range(1500)] + @given(st.lists(st.text(alphabet))) + def _(xs): + trie = datrie.Trie(alphabet) + for x in xs: + trie[x] = True - _() + for x in xs: + assert x in trie + + _() From 09cefa209ba82a238ca58c4afd993d37e8cf6bf2 Mon Sep 17 00:00:00 2001 From: c4f3a0ce <30480807+c4f3a0ce@users.noreply.github.com> Date: Sun, 8 Dec 2019 13:37:13 +0100 Subject: [PATCH 3/3] Remove 0 from test character range --- tests/test_trie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_trie.py b/tests/test_trie.py index f9ce379..3e6cb14 100644 --- a/tests/test_trie.py +++ b/tests/test_trie.py @@ -433,7 +433,7 @@ def test_trie_handles_long_alphabets(): if sys.version_info > (2, ): - alphabet = [chr(i) for i in range(1500)] + alphabet = [chr(i) for i in range(1, 1500)] @given(st.lists(st.text(alphabet))) def _(xs): trie = datrie.Trie(alphabet)