Mercurial > p > roundup > code
comparison test/test_indexer.py @ 5964:5bf7b5debb09
Fix xapian indexer for unicode
Make regular expression pattern match words as unicode.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 30 Oct 2019 17:56:18 -0400 |
| parents | 6137ea845438 |
| children | 9d209d2b34ae |
comparison
equal
deleted
inserted
replaced
| 5963:4c7662c86a36 | 5964:5bf7b5debb09 |
|---|---|
| 48 # https://github.com/pytest-dev/pytest/issues/568 | 48 # https://github.com/pytest-dev/pytest/issues/568 |
| 49 from .pytest_patcher import mark_class | 49 from .pytest_patcher import mark_class |
| 50 skip_whoosh = mark_class(pytest.mark.skip( | 50 skip_whoosh = mark_class(pytest.mark.skip( |
| 51 "Skipping Whoosh indexer tests: 'whoosh' not installed")) | 51 "Skipping Whoosh indexer tests: 'whoosh' not installed")) |
| 52 | 52 |
| 53 | |
| 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 | |
| 61 class db: | 53 class db: |
| 62 class config(dict): | 54 class config(dict): |
| 63 DATABASE = 'test-index' | 55 DATABASE = 'test-index' |
| 64 config = config() | 56 config = config() |
| 65 config[('main', 'indexer_stopwords')] = [] | 57 config[('main', 'indexer_stopwords')] = [] |
| 163 """Test if searches find many results.""" | 155 """Test if searches find many results.""" |
| 164 for i in range(123): | 156 for i in range(123): |
| 165 self.dex.add_text(('test', str(i), 'many'), 'many') | 157 self.dex.add_text(('test', str(i), 'many'), 'many') |
| 166 self.assertEqual(len(self.dex.find(['many'])), 123) | 158 self.assertEqual(len(self.dex.find(['many'])), 123) |
| 167 | 159 |
| 168 @unicode_fails_py2 | |
| 169 def test_unicode(self): | 160 def test_unicode(self): |
| 170 """Test with unicode words. see: | 161 """Test with unicode words. see: |
| 171 https://issues.roundup-tracker.org/issue1344046""" | 162 https://issues.roundup-tracker.org/issue1344046""" |
| 172 russian=u'\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442Spr\xfcnge' | 163 russian=u'\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0442\u0435\u043a\u0441\u0442Spr\xfcnge' |
| 173 german=u'Spr\xfcnge' | 164 german=u'Spr\xfcnge' |
