summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pydoc.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-08-19 05:25:16 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-08-19 05:25:16 (GMT)
commit95801bbe4e96aeb706c8fcf9fb3698c39a72b847 (patch)
tree997f06d37a9893afaf862d012a110a19f706b675 /Lib/test/test_pydoc.py
parent15b87bfedcd40f601cb3c9caf75d2366c48e19fc (diff)
downloadcpython-95801bbe4e96aeb706c8fcf9fb3698c39a72b847.zip
cpython-95801bbe4e96aeb706c8fcf9fb3698c39a72b847.tar.gz
cpython-95801bbe4e96aeb706c8fcf9fb3698c39a72b847.tar.bz2
Issue #24879: Teach pydoc to display named tuple fields in the order they were defined.
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r--Lib/test/test_pydoc.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index ec5c31b..0533a03 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -811,6 +811,22 @@ class TestDescriptions(unittest.TestCase):
self.assertEqual(self._get_summary_line(t.wrap),
"wrap(text) method of textwrap.TextWrapper instance")
+ def test_field_order_for_named_tuples(self):
+ Person = namedtuple('Person', ['nickname', 'firstname', 'agegroup'])
+ s = pydoc.render_doc(Person)
+ self.assertLess(s.index('nickname'), s.index('firstname'))
+ self.assertLess(s.index('firstname'), s.index('agegroup'))
+
+ class NonIterableFields:
+ _fields = None
+
+ class NonHashableFields:
+ _fields = [[]]
+
+ # Make sure these doesn't fail
+ pydoc.render_doc(NonIterableFields)
+ pydoc.render_doc(NonHashableFields)
+
@requires_docstrings
def test_bound_builtin_method(self):
s = StringIO()