2424import pytest
2525from 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+
2737config = configuration .CoreConfig ()
2838config .DATABASE = "db"
2939config .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