summaryrefslogtreecommitdiff
path: root/tests/test_ext_autodoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-23 02:38:53 +0900
committerGitHub <noreply@github.com>2020-05-23 02:38:53 +0900
commita1293e28251dcabdb9f9a42fc04a138904e545bc (patch)
tree9a0b04a98de83b3e0635828fb61ff52b6626a544 /tests/test_ext_autodoc.py
parent6a4148abecb778960a3ff8f8c76bd72fb91a7fa2 (diff)
parentf13e05a01b2dc5bf447c6a243cf0a90e9f25671c (diff)
downloadsphinx-git-a1293e28251dcabdb9f9a42fc04a138904e545bc.tar.gz
Merge pull request #7709 from tk0miya/refactor_test_ext_autodoc
refactor: test: Separate tests for autofunction
Diffstat (limited to 'tests/test_ext_autodoc.py')
-rw-r--r--tests/test_ext_autodoc.py138
1 files changed, 2 insertions, 136 deletions
diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py
index 50d641dc9..9dbc311b8 100644
--- a/tests/test_ext_autodoc.py
+++ b/tests/test_ext_autodoc.py
@@ -1,6 +1,6 @@
"""
- test_autodoc
- ~~~~~~~~~~~~
+ test_ext_autodoc
+ ~~~~~~~~~~~~~~~~
Test the autodoc extension. This tests mainly the Documenters; the auto
directives are tested in a test source file translated by test_build.
@@ -838,21 +838,6 @@ def test_autodoc_descriptor(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autodoc_c_module(app):
- actual = do_autodoc(app, 'function', 'time.asctime')
- assert list(actual) == [
- '',
- '.. py:function:: asctime([tuple]) -> string',
- ' :module: time',
- '',
- " Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.",
- ' When the time tuple is not present, current time as returned by localtime()',
- ' is used.',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_member_order(app):
# case member-order='bysource'
options = {"members": None,
@@ -1187,96 +1172,6 @@ def test_descriptor_class(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_classes(app):
- actual = do_autodoc(app, 'function', 'target.classes.Foo')
- assert list(actual) == [
- '',
- '.. py:function:: Foo()',
- ' :module: target.classes',
- '',
- ]
-
- actual = do_autodoc(app, 'function', 'target.classes.Bar')
- assert list(actual) == [
- '',
- '.. py:function:: Bar(x, y)',
- ' :module: target.classes',
- '',
- ]
-
- actual = do_autodoc(app, 'function', 'target.classes.Baz')
- assert list(actual) == [
- '',
- '.. py:function:: Baz(x, y)',
- ' :module: target.classes',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_callable(app):
- actual = do_autodoc(app, 'function', 'target.callable.function')
- assert list(actual) == [
- '',
- '.. py:function:: function(arg1, arg2, **kwargs)',
- ' :module: target.callable',
- '',
- ' A callable object that behaves like a function.',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_method(app):
- actual = do_autodoc(app, 'function', 'target.callable.method')
- assert list(actual) == [
- '',
- '.. py:function:: method(arg1, arg2)',
- ' :module: target.callable',
- '',
- ' docstring of Callable.method().',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_builtin(app):
- actual = do_autodoc(app, 'function', 'os.umask')
- assert list(actual) == [
- '',
- '.. py:function:: umask(mask, /)',
- ' :module: os',
- '',
- ' Set the current numeric umask and return the previous umask.',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_methoddescriptor(app):
- actual = do_autodoc(app, 'function', 'builtins.int.__add__')
- assert list(actual) == [
- '',
- '.. py:function:: int.__add__(self, value, /)',
- ' :module: builtins',
- '',
- ' Return self+value.',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_autofunction_for_decorated(app):
- actual = do_autodoc(app, 'function', 'target.decorator.foo')
- assert list(actual) == [
- '',
- '.. py:function:: foo()',
- ' :module: target.decorator',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_automethod_for_builtin(app):
actual = do_autodoc(app, 'method', 'builtins.int.__add__')
assert list(actual) == [
@@ -1496,19 +1391,6 @@ def test_partialmethod(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_wrappedfunction(app):
- actual = do_autodoc(app, 'function', 'target.wrappedfunction.slow_function')
- assert list(actual) == [
- '',
- '.. py:function:: slow_function(message, timeout)',
- ' :module: target.wrappedfunction',
- '',
- ' This function is slow.',
- '',
- ]
-
-
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_partialmethod_undoc_members(app):
expected = [
'',
@@ -1688,22 +1570,6 @@ def test_singledispatch(app):
]
-@pytest.mark.sphinx('html', testroot='ext-autodoc')
-def test_singledispatch_autofunction(app):
- options = {}
- actual = do_autodoc(app, 'function', 'target.singledispatch.func', options)
- assert list(actual) == [
- '',
- '.. py:function:: func(arg, kwarg=None)',
- ' func(arg: int, kwarg=None)',
- ' func(arg: str, kwarg=None)',
- ' :module: target.singledispatch',
- '',
- ' A function for general use.',
- '',
- ]
-
-
@pytest.mark.skipif(sys.version_info < (3, 8),
reason='singledispatchmethod is available since python3.8')
@pytest.mark.sphinx('html', testroot='ext-autodoc')