Fix #6451: autodoc: generates docs for "optional import"ed modules as variables

This commit is contained in:
Takeshi KOMIYA
2019-06-08 16:09:45 +09:00
parent f0b1cbb734
commit 0aed08b5be
3 changed files with 27 additions and 0 deletions

View File

@@ -149,6 +149,21 @@ def test_complex_assignment_py3():
assert parser.definitions == {}
def test_assignment_in_try_clause():
source = ('try:\n'
' a = None #: comment\n'
'except:\n'
' b = None #: ignored\n'
'else:\n'
' c = None #: comment\n')
parser = Parser(source)
parser.parse()
assert parser.comments == {('', 'a'): 'comment',
('', 'c'): 'comment'}
assert parser.deforders == {'a': 0,
'c': 1}
def test_obj_assignment():
source = ('obj = SomeObject() #: some object\n'
'obj.attr = 1 #: attr1\n'