changeset 6367:8a7de159d1a6

issue2551125 Make indexer_lang test work if xapian not installed. Reported by Ralf in https://issues.roundup-tracker.org/issue2551125.
author John Rouillard <rouilj@ieee.org>
date Wed, 31 Mar 2021 08:43:03 -0400
parents e8361bce72de
children e3ed3ad9e795
files test/test_config.py
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_config.py	Tue Mar 30 21:04:53 2021 -0400
+++ b/test/test_config.py	Wed Mar 31 08:43:03 2021 -0400
@@ -24,6 +24,16 @@
 import pytest
 from roundup import configuration
 
+try:
+    import xapian
+    skip_xapian = lambda func, *args, **kwargs: func
+except ImportError:
+    # FIX: workaround for a bug in pytest.mark.skip():
+    #   https://github.com/pytest-dev/pytest/issues/568
+    from .pytest_patcher import mark_class
+    skip_xapian = mark_class(pytest.mark.skip(
+        "Skipping Xapian indexer tests: 'xapian' not installed"))
+
 config = configuration.CoreConfig()
 config.DATABASE = "db"
 config.RDBMS_NAME = "rounduptest"
@@ -372,6 +382,7 @@
         self.assertEqual("RDBMS_BACKEND is not set"
                       " and has no default", cm.exception.__str__())
 
+    @skip_xapian
     def testInvalidIndexerLanguage_w_empty(self):
         """ make sure we have a reasonable error message if
             invalid indexer language is specified. This uses
@@ -414,7 +425,8 @@
 
         # need to delete both to make python2 not error finding _xapian
         del(sys.modules['xapian'])
-        del(sys.modules['xapian._xapian'])
+        if xapian._xapian in sys.modules:
+            del(sys.modules['xapian._xapian'])
 
         self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
 
@@ -438,6 +450,7 @@
         self.assertEqual(config['HTML_VERSION'], 'html4')
         self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
 
+    @skip_xapian
     def testInvalidIndexerLanguage_w_xapian(self):
         """ Use explicit xapian indexer. Verify exception is
             generated.

Roundup Issue Tracker: http://roundup-tracker.org/