Skip to content

Commit 2eb2fb4

Browse files
committed
Add test for issue1344046 and maybe issue1195739
Python3 should be properly indexing unicode words while python2 doesn't. Add test (xfail for python 2) for this. So far I have passing on python3 (tested 4 of 6 indexers) and fail on 2 of 6 and xpass on 2 of 6 under python2.
1 parent 29cf1a2 commit 2eb2fb4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/test_indexer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
"Skipping Whoosh indexer tests: 'whoosh' not installed"))
5252

5353

54+
import sys
55+
if sys.version_info[0] > 2:
56+
unicode_fails_py2 = lambda func, *args, **kwargs: func
57+
else:
58+
unicode_fails_py2 = pytest.mark.xfail(
59+
reason="Unicode indexing expected to fail under python 2")
60+
5461
class db:
5562
class config(dict):
5663
DATABASE = 'test-index'
@@ -158,6 +165,15 @@ def test_manyresults(self):
158165
self.dex.add_text(('test', str(i), 'many'), 'many')
159166
self.assertEqual(len(self.dex.find(['many'])), 123)
160167

168+
@unicode_fails_py2
169+
def test_unicode(self):
170+
"""Test with unicode words. see:
171+
https://issues.roundup-tracker.org/issue1344046"""
172+
173+
self.dex.add_text(('test', '1', 'a'), u'Spr\xfcnge')
174+
self.assertSeqEqual(self.dex.find([u'Spr\xfcnge']),
175+
[('test', '1', 'a')])
176+
161177
def tearDown(self):
162178
shutil.rmtree('test-index')
163179

0 commit comments

Comments
 (0)