mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve websupport test skipping, add new decorator for search adapter skipping.
This commit is contained in:
parent
9acc57b616
commit
2f2a09c919
@ -12,9 +12,13 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
from util import *
|
from nose import SkipTest
|
||||||
|
|
||||||
from sphinx.websupport import WebSupport
|
from sphinx.websupport import WebSupport
|
||||||
|
|
||||||
|
from test_websupport import sqlalchemy_missing
|
||||||
|
from util import *
|
||||||
|
|
||||||
|
|
||||||
def clear_builddir():
|
def clear_builddir():
|
||||||
(test_root / 'websupport').rmtree(True)
|
(test_root / 'websupport').rmtree(True)
|
||||||
@ -63,21 +67,13 @@ def search_adapter_helper(adapter):
|
|||||||
html = support.get_search_results(u'SomeLongRandomWord')
|
html = support.get_search_results(u'SomeLongRandomWord')
|
||||||
|
|
||||||
|
|
||||||
|
@skip_unless_importable('xapian', 'needs xapian bindings installed')
|
||||||
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
def test_xapian():
|
def test_xapian():
|
||||||
# Don't run tests if xapian is not installed.
|
|
||||||
try:
|
|
||||||
import xapian
|
|
||||||
search_adapter_helper('xapian')
|
search_adapter_helper('xapian')
|
||||||
except ImportError:
|
|
||||||
sys.stderr.write('info: not running xapian tests, ' \
|
|
||||||
'xapian doesn\'t seem to be installed')
|
|
||||||
|
|
||||||
|
|
||||||
|
@skip_unless_importable('whoosh', 'needs whoosh package installed')
|
||||||
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
def test_whoosh():
|
def test_whoosh():
|
||||||
# Don't run tests if whoosh is not installed.
|
|
||||||
try:
|
|
||||||
import whoosh
|
|
||||||
search_adapter_helper('whoosh')
|
search_adapter_helper('whoosh')
|
||||||
except ImportError:
|
|
||||||
sys.stderr.write('info: not running whoosh tests, ' \
|
|
||||||
'whoosh doesn\'t seem to be installed')
|
|
||||||
|
@ -22,6 +22,7 @@ from nose import SkipTest
|
|||||||
|
|
||||||
from sphinx.websupport import WebSupport
|
from sphinx.websupport import WebSupport
|
||||||
from sphinx.websupport.errors import *
|
from sphinx.websupport.errors import *
|
||||||
|
from sphinx.websupport.storage import StorageBackend
|
||||||
from sphinx.websupport.storage.differ import CombinedHtmlDiff
|
from sphinx.websupport.storage.differ import CombinedHtmlDiff
|
||||||
try:
|
try:
|
||||||
from sphinx.websupport.storage.sqlalchemystorage import Session, \
|
from sphinx.websupport.storage.sqlalchemystorage import Session, \
|
||||||
@ -57,17 +58,23 @@ def with_support(*args, **kwargs):
|
|||||||
return generator
|
return generator
|
||||||
|
|
||||||
|
|
||||||
@with_support()
|
class NullStorage(StorageBackend):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@with_support(storage=NullStorage())
|
||||||
def test_no_srcdir(support):
|
def test_no_srcdir(support):
|
||||||
"""Make sure the correct exception is raised if srcdir is not given."""
|
"""Make sure the correct exception is raised if srcdir is not given."""
|
||||||
raises(SrcdirNotSpecifiedError, support.build)
|
raises(SrcdirNotSpecifiedError, support.build)
|
||||||
|
|
||||||
|
|
||||||
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
@with_support(srcdir=test_root)
|
@with_support(srcdir=test_root)
|
||||||
def test_build(support):
|
def test_build(support):
|
||||||
support.build()
|
support.build()
|
||||||
|
|
||||||
|
|
||||||
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
@with_support()
|
@with_support()
|
||||||
def test_get_document(support):
|
def test_get_document(support):
|
||||||
raises(DocumentNotFoundError, support.get_document, 'nonexisting')
|
raises(DocumentNotFoundError, support.get_document, 'nonexisting')
|
||||||
|
@ -29,8 +29,8 @@ from nose import tools, SkipTest
|
|||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'test_root',
|
'test_root', 'raises', 'raises_msg',
|
||||||
'raises', 'raises_msg', 'skip_if', 'skip_unless', 'Struct',
|
'skip_if', 'skip_unless', 'skip_unless_importable', 'Struct',
|
||||||
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
|
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
|
||||||
'path', 'with_tempdir', 'write_file',
|
'path', 'with_tempdir', 'write_file',
|
||||||
'sprint', 'remove_unicode_literals',
|
'sprint', 'remove_unicode_literals',
|
||||||
@ -86,6 +86,15 @@ def skip_unless(condition, msg=None):
|
|||||||
"""Decorator to skip test if condition is false."""
|
"""Decorator to skip test if condition is false."""
|
||||||
return skip_if(not condition, msg)
|
return skip_if(not condition, msg)
|
||||||
|
|
||||||
|
def skip_unless_importable(module, msg=None):
|
||||||
|
"""Decorator to skip test if module is not importable."""
|
||||||
|
try:
|
||||||
|
__import__(module)
|
||||||
|
except ImportError:
|
||||||
|
return skip_if(True, msg)
|
||||||
|
else:
|
||||||
|
return skip_if(False, msg)
|
||||||
|
|
||||||
|
|
||||||
class Struct(object):
|
class Struct(object):
|
||||||
def __init__(self, **kwds):
|
def __init__(self, **kwds):
|
||||||
|
Loading…
Reference in New Issue
Block a user