2010-07-30 11:20:43 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_websupport
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the Web Support Package
|
|
|
|
|
|
|
|
:copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
|
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
from StringIO import StringIO
|
|
|
|
|
|
|
|
from sphinx.websupport import WebSupport
|
2010-07-30 15:53:02 -05:00
|
|
|
from sphinx.websupport.errors import DocumentNotFoundError
|
2010-07-30 11:20:43 -05:00
|
|
|
|
|
|
|
try:
|
|
|
|
from functools import wraps
|
|
|
|
except ImportError:
|
|
|
|
# functools is new in 2.4
|
|
|
|
wraps = lambda f: (lambda w: w)
|
|
|
|
|
|
|
|
from util import *
|
|
|
|
|
|
|
|
def teardown_module():
|
|
|
|
(test_root / 'websupport').rmtree(True)
|
|
|
|
|
|
|
|
def with_support(*args, **kwargs):
|
|
|
|
"""Make a WebSupport object and pass it the test."""
|
|
|
|
settings = {'srcdir': test_root,
|
|
|
|
'outdir': os.path.join(test_root, 'websupport'),
|
|
|
|
'status': StringIO(),
|
|
|
|
'warning': StringIO()}
|
|
|
|
settings.update(kwargs)
|
|
|
|
|
|
|
|
def generator(func):
|
|
|
|
@wraps(func)
|
|
|
|
def new_func(*args2, **kwargs2):
|
|
|
|
support = WebSupport(**settings)
|
|
|
|
func(support, *args2, **kwargs2)
|
|
|
|
return new_func
|
|
|
|
return generator
|
|
|
|
|
|
|
|
@with_support()
|
|
|
|
def test_build(support):
|
|
|
|
support.build()
|
2010-07-30 15:53:02 -05:00
|
|
|
raises(DocumentNotFoundError, support.get_document, 'nonexisting')
|
2010-07-30 11:20:43 -05:00
|
|
|
|