Fix compatibility with Sphinx 2.1
- Fix deprecation warnings - Fix missing API in tests - Fix relative imports in tests - use proper logger
This commit is contained in:
parent
fc809c1041
commit
585085250e
4 changed files with 48 additions and 37 deletions
|
@ -29,13 +29,11 @@ def run(extra_args=[]):
|
|||
print("The sphinx package is needed to run the jandd.sphinxext.ip "
|
||||
"test suite.")
|
||||
|
||||
import test_ip
|
||||
from .test_ip import TestIPExtension
|
||||
|
||||
print("Running jandd.sphinxext.ip test suite ...")
|
||||
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(
|
||||
test_ip.TestIPExtension
|
||||
)
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestIPExtension)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from io import StringIO
|
||||
from util import TestApp, test_root
|
||||
from .util import TestApp, test_root
|
||||
import unittest
|
||||
|
||||
|
||||
|
|
|
@ -7,21 +7,14 @@
|
|||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import io
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
try:
|
||||
from functools import wraps
|
||||
except ImportError:
|
||||
# functools is new in 2.4
|
||||
wraps = lambda f: (lambda w: w)
|
||||
|
||||
from sphinx import application
|
||||
from sphinx.ext.autodoc import AutoDirective
|
||||
import sys
|
||||
import tempfile
|
||||
from functools import wraps
|
||||
|
||||
from path import Path
|
||||
from sphinx import application
|
||||
|
||||
__all__ = [
|
||||
'test_root',
|
||||
|
@ -40,6 +33,7 @@ def _excstr(exc):
|
|||
return str(tuple(map(_excstr, exc)))
|
||||
return exc.__name__
|
||||
|
||||
|
||||
def raises(exc, func, *args, **kwds):
|
||||
"""
|
||||
Raise :exc:`AssertionError` if ``func(*args, **kwds)`` does not
|
||||
|
@ -53,6 +47,7 @@ def raises(exc, func, *args, **kwds):
|
|||
raise AssertionError('%s did not raise %s' %
|
||||
(func.__name__, _excstr(exc)))
|
||||
|
||||
|
||||
def raises_msg(exc, msg, func, *args, **kwds):
|
||||
"""
|
||||
Raise :exc:`AssertionError` if ``func(*args, **kwds)`` does not
|
||||
|
@ -71,6 +66,7 @@ class Struct(object):
|
|||
def __init__(self, **kwds):
|
||||
self.__dict__.update(kwds)
|
||||
|
||||
|
||||
class ListOutput(object):
|
||||
"""
|
||||
File-like object that collects written text in a list.
|
||||
|
@ -85,6 +81,7 @@ class ListOutput(object):
|
|||
def write(self, text):
|
||||
self.content.append(text)
|
||||
|
||||
|
||||
class TestApp(application.Sphinx):
|
||||
"""
|
||||
A subclass of :class:`Sphinx` that runs on the test root, with some
|
||||
|
@ -139,7 +136,6 @@ class TestApp(application.Sphinx):
|
|||
freshenv, warningiserror, tags)
|
||||
|
||||
def cleanup(self, doctrees=False):
|
||||
AutoDirective._registry.clear()
|
||||
for tree in self.cleanup_trees:
|
||||
shutil.rmtree(tree, True)
|
||||
|
||||
|
@ -176,6 +172,7 @@ def gen_with_app(*args, **kwargs):
|
|||
return deco
|
||||
return generator
|
||||
|
||||
|
||||
def with_tempdir(func):
|
||||
def new_func():
|
||||
tempdir = Path(tempfile.mkdtemp())
|
||||
|
@ -184,10 +181,12 @@ def with_tempdir(func):
|
|||
new_func.__name__ = func.__name__
|
||||
return new_func
|
||||
|
||||
|
||||
def write_file(name, contents):
|
||||
f = open(str(name), 'wb')
|
||||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
|
||||
def sprint(*args):
|
||||
sys.stderr.write(' '.join(map(str, args)) + '\n')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue