diff options
author | Georg Brandl <georg@python.org> | 2014-11-07 15:03:06 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-11-07 15:03:06 +0100 |
commit | bbd315b82e65b9ebdf7523d70e2c51139e61a51e (patch) | |
tree | b120963d1c68b17ef48583a691ef65566e97316f /tests/test_autodoc.py | |
parent | 0889073f35d4cdce8f379da308bd62f5f50dd7b0 (diff) | |
parent | fa09ec000f5209076f1f886fcb909f5ffea718d6 (diff) | |
download | sphinx-git-bbd315b82e65b9ebdf7523d70e2c51139e61a51e.tar.gz |
merge with stable
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r-- | tests/test_autodoc.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 10921b652..96e46196a 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -151,9 +151,12 @@ def test_format_signature(): inst.fullname = name inst.doc_as_attr = False # for class objtype inst.object = obj + inst.objpath = [name] inst.args = args inst.retann = retann - return inst.format_signature() + res = inst.format_signature() + print res + return res # no signatures for modules assert formatsig('module', 'test', None, None, None) == '' @@ -186,7 +189,8 @@ def test_format_signature(): assert formatsig('class', 'C', C, None, None) == '(a, b=None)' assert formatsig('class', 'C', D, 'a, b', 'X') == '(a, b) -> X' - #__init__ have signature at first line of docstring + # __init__ have signature at first line of docstring + directive.env.config.autoclass_content = 'both' class F2: '''some docstring for F2.''' def __init__(self, *args, **kw): @@ -197,9 +201,11 @@ def test_format_signature(): ''' class G2(F2, object): pass - for C in (F2, G2): - assert formatsig('class', 'C', C, None, None) == \ - '(a1, a2, kw1=True, kw2=False)' + + assert formatsig('class', 'F2', F2, None, None) == \ + '(a1, a2, kw1=True, kw2=False)' + assert formatsig('class', 'G2', G2, None, None) == \ + '(a1, a2, kw1=True, kw2=False)' # test for methods class H: @@ -215,6 +221,7 @@ def test_format_signature(): assert formatsig('method', 'H.foo', H.foo3, None, None) == r"(d='\\n')" # test exception handling (exception is caught and args is '') + directive.env.config.autodoc_docstring_signature = False assert formatsig('function', 'int', int, None, None) == '' del _warnings[:] @@ -242,9 +249,14 @@ def test_get_doc(): def getdocl(objtype, obj, encoding=None): inst = AutoDirective._registry[objtype](directive, 'tmp') inst.object = obj + inst.objpath = [obj.__name__] + inst.doc_as_attr = False + inst.format_signature() # handle docstring signatures! ds = inst.get_doc(encoding) # for testing purposes, concat them and strip the empty line at the end - return sum(ds, [])[:-1] + res = sum(ds, [])[:-1] + print res + return res # objects without docstring def f(): @@ -305,7 +317,7 @@ def test_get_doc(): assert getdocl('class', D) == ['Class docstring', '', 'Init docstring', '', 'Other', ' lines'] - #__init__ have signature at first line of docstring + # __init__ have signature at first line of docstring class E: """Class docstring""" def __init__(self, *args, **kw): @@ -330,7 +342,7 @@ def test_get_doc(): # signature line in the docstring will be removed when # autodoc_docstring_signature == True - directive.env.config.autodoc_docstring_signature = True #default + directive.env.config.autodoc_docstring_signature = True # default directive.env.config.autoclass_content = 'class' assert getdocl('class', E) == ['Class docstring'] directive.env.config.autoclass_content = 'init' |