summaryrefslogtreecommitdiff
path: root/tests/test_autodoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r--tests/test_autodoc.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index 22eb02b34..06a3faf43 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -10,8 +10,7 @@
:license: BSD, see LICENSE for details.
"""
-# "raises" imported for usage by autodoc
-from util import TestApp, Struct, raises, SkipTest # NOQA
+from util import SphinxTestApp, Struct # NOQA
import pytest
import enum
@@ -26,7 +25,7 @@ app = None
def setup_module():
global app
- app = TestApp()
+ app = SphinxTestApp()
app.builder.env.app = app
app.builder.env.temp_data['docname'] = 'dummy'
app.connect('autodoc-process-docstring', process_docstring)
@@ -125,26 +124,27 @@ def test_parse_name():
del _warnings[:]
# for functions/classes
- verify('function', 'util.raises', ('util', ['raises'], None, None))
- verify('function', 'util.raises(exc) -> None',
- ('util', ['raises'], 'exc', 'None'))
- directive.env.temp_data['autodoc:module'] = 'util'
- verify('function', 'raises', ('util', ['raises'], None, None))
+ verify('function', 'test_autodoc.raises',
+ ('test_autodoc', ['raises'], None, None))
+ verify('function', 'test_autodoc.raises(exc) -> None',
+ ('test_autodoc', ['raises'], 'exc', 'None'))
+ directive.env.temp_data['autodoc:module'] = 'test_autodoc'
+ verify('function', 'raises', ('test_autodoc', ['raises'], None, None))
del directive.env.temp_data['autodoc:module']
- directive.env.ref_context['py:module'] = 'util'
- verify('function', 'raises', ('util', ['raises'], None, None))
- verify('class', 'TestApp', ('util', ['TestApp'], None, None))
+ directive.env.ref_context['py:module'] = 'test_autodoc'
+ verify('function', 'raises', ('test_autodoc', ['raises'], None, None))
+ verify('class', 'Base', ('test_autodoc', ['Base'], None, None))
# for members
directive.env.ref_context['py:module'] = 'foo'
- verify('method', 'util.TestApp.cleanup',
- ('util', ['TestApp', 'cleanup'], None, None))
+ verify('method', 'util.SphinxTestApp.cleanup',
+ ('util', ['SphinxTestApp', 'cleanup'], None, None))
directive.env.ref_context['py:module'] = 'util'
directive.env.ref_context['py:class'] = 'Foo'
- directive.env.temp_data['autodoc:class'] = 'TestApp'
- verify('method', 'cleanup', ('util', ['TestApp', 'cleanup'], None, None))
- verify('method', 'TestApp.cleanup',
- ('util', ['TestApp', 'cleanup'], None, None))
+ directive.env.temp_data['autodoc:class'] = 'SphinxTestApp'
+ verify('method', 'cleanup', ('util', ['SphinxTestApp', 'cleanup'], None, None))
+ verify('method', 'SphinxTestApp.cleanup',
+ ('util', ['SphinxTestApp', 'cleanup'], None, None))
# and clean up
del directive.env.ref_context['py:module']
@@ -658,7 +658,7 @@ def test_generate():
'Class.meth', more_content=add_content)
# test check_module
- inst = FunctionDocumenter(directive, 'raises')
+ inst = FunctionDocumenter(directive, 'add_documenter')
inst.generate(check_module=True)
assert len(directive.result) == 0
@@ -878,6 +878,11 @@ __all__ = ['Class']
integer = 1
+def raises(exc, func, *args, **kwds):
+ """Raise AssertionError if ``func(*args, **kwds)`` does not raise *exc*."""
+ pass
+
+
class CustomEx(Exception):
"""My custom exception."""
@@ -1086,7 +1091,7 @@ def test_type_hints():
try:
from typing_test_data import f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11
except (ImportError, SyntaxError):
- raise SkipTest('Cannot import Python code with function annotations')
+ pytest.skip('Cannot import Python code with function annotations')
def verify_arg_spec(f, expected):
assert formatargspec(f, *getargspec(f)) == expected