Skip to content

Commit 8b3cb42

Browse files
committed
issue2551125 Make indexer_lang test work if xapian not installed.
Reported by Ralf in https://issues.roundup-tracker.org/issue2551125.
1 parent 435d83e commit 8b3cb42

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/test_config.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
import pytest
2525
from roundup import configuration
2626

27+
try:
28+
import xapian
29+
skip_xapian = lambda func, *args, **kwargs: func
30+
except ImportError:
31+
# FIX: workaround for a bug in pytest.mark.skip():
32+
# https://github.com/pytest-dev/pytest/issues/568
33+
from .pytest_patcher import mark_class
34+
skip_xapian = mark_class(pytest.mark.skip(
35+
"Skipping Xapian indexer tests: 'xapian' not installed"))
36+
2737
config = configuration.CoreConfig()
2838
config.DATABASE = "db"
2939
config.RDBMS_NAME = "rounduptest"
@@ -372,6 +382,7 @@ def testNoDBInConfig(self):
372382
self.assertEqual("RDBMS_BACKEND is not set"
373383
" and has no default", cm.exception.__str__())
374384

385+
@skip_xapian
375386
def testInvalidIndexerLanguage_w_empty(self):
376387
""" make sure we have a reasonable error message if
377388
invalid indexer language is specified. This uses
@@ -414,7 +425,8 @@ def testInvalidIndexerLanguage_xapian_missing(self):
414425

415426
# need to delete both to make python2 not error finding _xapian
416427
del(sys.modules['xapian'])
417-
del(sys.modules['xapian._xapian'])
428+
if xapian._xapian in sys.modules:
429+
del(sys.modules['xapian._xapian'])
418430

419431
self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
420432

@@ -438,6 +450,7 @@ def testInvalidIndexerLanguage_w_native(self):
438450
self.assertEqual(config['HTML_VERSION'], 'html4')
439451
self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
440452

453+
@skip_xapian
441454
def testInvalidIndexerLanguage_w_xapian(self):
442455
""" Use explicit xapian indexer. Verify exception is
443456
generated.

0 commit comments

Comments
 (0)