Skip to content

Commit 7f3552a

Browse files
committed
issue2551125 Add indexer_lang test that runs if xapian not installed
Test case for xapian not installed. Same test as testInvalidIndexerLanguage_xapian_missing except without magling sys.modules.
1 parent 8b3cb42 commit 7f3552a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test_config.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@
2727
try:
2828
import xapian
2929
skip_xapian = lambda func, *args, **kwargs: func
30+
from .pytest_patcher import mark_class
31+
include_no_xapian = mark_class(pytest.mark.skip(
32+
"Skipping missing Xapian indexer tests: 'xapian' is installed"))
3033
except ImportError:
3134
# FIX: workaround for a bug in pytest.mark.skip():
3235
# https://github.com/pytest-dev/pytest/issues/568
3336
from .pytest_patcher import mark_class
3437
skip_xapian = mark_class(pytest.mark.skip(
3538
"Skipping Xapian indexer tests: 'xapian' not installed"))
39+
include_no_xapian = lambda func, *args, **kwargs: func
40+
3641

3742
config = configuration.CoreConfig()
3843
config.DATABASE = "db"
@@ -406,6 +411,25 @@ def testInvalidIndexerLanguage_w_empty(self):
406411
# look for supported language
407412
self.assertIn("english", cm.exception.args[2])
408413

414+
@include_no_xapian
415+
def testInvalidIndexerLanguage_w_empty_no_xapian(self):
416+
""" Test case for empty indexer if xapian really isn't installed
417+
418+
This should behave like testInvalidIndexerLanguage_xapian_missing
419+
but without all the sys.modules mangling.
420+
"""
421+
print("Testing when xapian is not installed")
422+
423+
# SETUP: set indexer_language value to an invalid value.
424+
self.munge_configini(mods=[ ("indexer = ", ""),
425+
("indexer_language = ", "NO_LANG") ])
426+
427+
config = configuration.CoreConfig()
428+
429+
config.load(self.dirname)
430+
431+
self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
432+
409433
def testInvalidIndexerLanguage_xapian_missing(self):
410434
"""Using default path for indexers, make import of xapian
411435
fail and prevent exception from happening even though

0 commit comments

Comments
 (0)