diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-12-19 13:18:58 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-19 13:18:58 +0900 |
| commit | cacbca6dd43747c9b66d862ca339036de9a3a166 (patch) | |
| tree | 6fecb9037212cecefcdb36d296d9cf662bfa8acb /tests/test_pycode.py | |
| parent | ed571ee2c09015465eb23a4f10b1f1e652c3a991 (diff) | |
| parent | e7e08d2a784d1e87aded58186bff776d6de42213 (diff) | |
| download | sphinx-git-cacbca6dd43747c9b66d862ca339036de9a3a166.tar.gz | |
Merge pull request #9987 from tk0miya/9968_ivar_not_shown
Fix #9968: autodoc: ivars are not shown if __init__ has posonlyargs
Diffstat (limited to 'tests/test_pycode.py')
| -rw-r--r-- | tests/test_pycode.py | 15 |
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} |
