summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-05 01:51:17 +0900
committerGitHub <noreply@github.com>2020-11-05 01:51:17 +0900
commitf46c14bbcaf04eae00436b8eaebb26d73a2e1ada (patch)
tree61af9bf15221aacc59ca611b5c1a1cfd33cc3ab5 /tests
parent2be6aaa7a45d5589aecbe36dfa7911c3bdbecff7 (diff)
parent9f1c89dd9d5139dfa8af43f9b552d549fb93d910 (diff)
downloadsphinx-git-f46c14bbcaf04eae00436b8eaebb26d73a2e1ada.tar.gz
Merge pull request #8355 from sphinx-doc/7613_class__signature__
Fix #7613: autodoc: autodoc does not respect __signature__ of the class
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/classes.py11
-rw-r--r--tests/test_ext_autodoc_autoclass.py50
-rw-r--r--tests/test_ext_autodoc_autofunction.py8
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/roots/test-ext-autodoc/target/classes.py b/tests/roots/test-ext-autodoc/target/classes.py
index dc471a6f3..52c23748b 100644
--- a/tests/roots/test-ext-autodoc/target/classes.py
+++ b/tests/roots/test-ext-autodoc/target/classes.py
@@ -1,3 +1,6 @@
+from inspect import Parameter, Signature
+
+
class Foo:
pass
@@ -10,3 +13,11 @@ class Bar:
class Baz:
def __new__(cls, x, y):
pass
+
+
+class Qux:
+ __signature__ = Signature(parameters=[Parameter('foo', Parameter.POSITIONAL_OR_KEYWORD),
+ Parameter('bar', Parameter.POSITIONAL_OR_KEYWORD)])
+
+ def __init__(self, x, y):
+ pass
diff --git a/tests/test_ext_autodoc_autoclass.py b/tests/test_ext_autodoc_autoclass.py
new file mode 100644
index 000000000..89a79c2c7
--- /dev/null
+++ b/tests/test_ext_autodoc_autoclass.py
@@ -0,0 +1,50 @@
+"""
+ test_ext_autodoc_autoclass
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Test the autodoc extension. This tests mainly the Documenters; the auto
+ directives are tested in a test source file translated by test_build.
+
+ :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import pytest
+
+from test_ext_autodoc import do_autodoc
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_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',
+ '',
+ ]
+
+ actual = do_autodoc(app, 'function', 'target.classes.Qux')
+ assert list(actual) == [
+ '',
+ '.. py:function:: Qux(foo, bar)',
+ ' :module: target.classes',
+ '',
+ ]
+
diff --git a/tests/test_ext_autodoc_autofunction.py b/tests/test_ext_autodoc_autofunction.py
index 1f68c0319..3c8165995 100644
--- a/tests/test_ext_autodoc_autofunction.py
+++ b/tests/test_ext_autodoc_autofunction.py
@@ -42,6 +42,14 @@ def test_classes(app):
'',
]
+ actual = do_autodoc(app, 'function', 'target.classes.Qux')
+ assert list(actual) == [
+ '',
+ '.. py:function:: Qux(foo, bar)',
+ ' :module: target.classes',
+ '',
+ ]
+
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_callable(app):