Mercurial > p > roundup > code
comparison test/test_indexer.py @ 5960:0db2621b6fee
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 29 Oct 2019 21:33:10 -0400 |
| parents | f8893e1cde0d |
| children | f6c58a7b535c |
comparison
equal
deleted
inserted
replaced
| 5959:1788c4b68620 | 5960:0db2621b6fee |
|---|---|
| 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 | 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 | |
| 54 class db: | 61 class db: |
| 55 class config(dict): | 62 class config(dict): |
| 56 DATABASE = 'test-index' | 63 DATABASE = 'test-index' |
| 57 config = config() | 64 config = config() |
| 58 config[('main', 'indexer_stopwords')] = [] | 65 config[('main', 'indexer_stopwords')] = [] |
| 156 """Test if searches find many results.""" | 163 """Test if searches find many results.""" |
| 157 for i in range(123): | 164 for i in range(123): |
| 158 self.dex.add_text(('test', str(i), 'many'), 'many') | 165 self.dex.add_text(('test', str(i), 'many'), 'many') |
| 159 self.assertEqual(len(self.dex.find(['many'])), 123) | 166 self.assertEqual(len(self.dex.find(['many'])), 123) |
| 160 | 167 |
| 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 | |
| 161 def tearDown(self): | 177 def tearDown(self): |
| 162 shutil.rmtree('test-index') | 178 shutil.rmtree('test-index') |
| 163 | 179 |
| 164 @skip_whoosh | 180 @skip_whoosh |
| 165 class WhooshIndexerTest(IndexerTest): | 181 class WhooshIndexerTest(IndexerTest): |
