summaryrefslogtreecommitdiff
path: root/tests/test_pycode.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-12-24 01:54:35 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-12-24 01:54:35 +0900
commitb5a9a056020e6bf5424a77a350b3204fd0e79a5a (patch)
treeb17136105a8612ce3ddd0ff3dc850fbf2fc1b73f /tests/test_pycode.py
parentf2dc8a999a589bc7a9a85f6f0dd5691aabc17062 (diff)
parent6ad6594ec73d44d51c18faf0f41dd92f958cc45b (diff)
downloadsphinx-git-b5a9a056020e6bf5424a77a350b3204fd0e79a5a.tar.gz
Merge branch '4.x' into drop-translator-specific-unknown_visit-calls
Diffstat (limited to 'tests/test_pycode.py')
-rw-r--r--tests/test_pycode.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_pycode.py b/tests/test_pycode.py
index bbcc42a52..e0e0fdb11 100644
--- a/tests/test_pycode.py
+++ b/tests/test_pycode.py
@@ -191,3 +191,18 @@ def test_ModuleAnalyzer_find_attr_docs():
'Qux': 15,
'Qux.attr1': 16,
'Qux.attr2': 17}
+
+
+@pytest.mark.skipif(sys.version_info < (3, 8),
+ reason='posonlyargs are available since python3.8.')
+def test_ModuleAnalyzer_find_attr_docs_for_posonlyargs_method():
+ code = ('class Foo(object):\n'
+ ' def __init__(self, /):\n'
+ ' self.attr = None #: attribute comment\n')
+ analyzer = ModuleAnalyzer.for_string(code, 'module')
+ docs = analyzer.find_attr_docs()
+ assert set(docs) == {('Foo', 'attr')}
+ assert docs[('Foo', 'attr')] == ['attribute comment', '']
+ assert analyzer.tagorder == {'Foo': 0,
+ 'Foo.__init__': 1,
+ 'Foo.attr': 2}