summaryrefslogtreecommitdiff
path: root/tests/test_autodoc.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-08 23:45:58 +0100
committerGeorg Brandl <georg@python.org>2011-01-08 23:45:58 +0100
commit8b63a39b1387bd27b9761f026f14b6f61c469c0b (patch)
treed5a84306f919023fa18bf78c207aa3c572fb68ca /tests/test_autodoc.py
parent6dc2d5f76bd882f497daf8ff530f15ca8a0244d6 (diff)
downloadsphinx-8b63a39b1387bd27b9761f026f14b6f61c469c0b.tar.gz
#437: autodoc now shows values of class data attributes.
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r--tests/test_autodoc.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index b0da900e..c482315a 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -341,6 +341,7 @@ def test_generate():
inst = AutoDirective._registry[objtype](directive, name)
inst.generate(**kw)
assert directive.result
+ #print '\n'.join(directive.result)
assert len(_warnings) == 0, _warnings
del directive.result[:]
@@ -430,7 +431,8 @@ def test_generate():
options.members = ALL
assert_processes(should, 'class', 'Class')
options.undoc_members = True
- should.extend((('method', 'test_autodoc.Class.undocmeth'),
+ should.extend((('attribute', 'test_autodoc.Class.skipattr'),
+ ('method', 'test_autodoc.Class.undocmeth'),
('method', 'test_autodoc.Class.roger')))
assert_processes(should, 'class', 'Class')
options.inherited_members = True
@@ -519,11 +521,24 @@ def test_generate():
'.. py:classmethod:: Class.moore(a, e, f) -> happiness', 'method',
'test_autodoc.Class.moore')
+ # test new attribute documenter behavior
+ directive.env.temp_data['py:module'] = 'test_autodoc'
+ options.undoc_members = True
+ assert_processes([('class', 'test_autodoc.AttCls'),
+ ('attribute', 'test_autodoc.AttCls.a1'),
+ ('attribute', 'test_autodoc.AttCls.a2'),
+ ], 'class', 'AttCls')
+ assert_result_contains(
+ ' :annotation: = hello world', 'attribute', 'AttCls.a1')
+ assert_result_contains(
+ ' :annotation: = None', 'attribute', 'AttCls.a2')
+
# --- generate fodder ------------
__all__ = ['Class']
+#: documentation for the integer
integer = 1
class CustomEx(Exception):
@@ -642,3 +657,11 @@ First line of docstring
rest of docstring
"""
+
+class StrRepr(str):
+ def __repr__(self):
+ return self
+
+class AttCls(object):
+ a1 = StrRepr('hello\nworld')
+ a2 = None