|
27 | 27 | try: |
28 | 28 | import xapian |
29 | 29 | 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")) |
30 | 33 | except ImportError: |
31 | 34 | # FIX: workaround for a bug in pytest.mark.skip(): |
32 | 35 | # https://github.com/pytest-dev/pytest/issues/568 |
33 | 36 | from .pytest_patcher import mark_class |
34 | 37 | skip_xapian = mark_class(pytest.mark.skip( |
35 | 38 | "Skipping Xapian indexer tests: 'xapian' not installed")) |
| 39 | + include_no_xapian = lambda func, *args, **kwargs: func |
| 40 | + |
36 | 41 |
|
37 | 42 | config = configuration.CoreConfig() |
38 | 43 | config.DATABASE = "db" |
@@ -406,6 +411,25 @@ def testInvalidIndexerLanguage_w_empty(self): |
406 | 411 | # look for supported language |
407 | 412 | self.assertIn("english", cm.exception.args[2]) |
408 | 413 |
|
| 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 | + |
409 | 433 | def testInvalidIndexerLanguage_xapian_missing(self): |
410 | 434 | """Using default path for indexers, make import of xapian |
411 | 435 | fail and prevent exception from happening even though |
|
0 commit comments