bpo-32492: Tweak _collections._tuplegetter. (GH-11367)

* Replace the docstrings cache with sys.intern().
* Improve tests.
* Unify names of tp_descr_get and tp_descr_set functions.
This commit is contained in:
Serhiy Storchaka 2018-12-31 14:15:16 +02:00 committed by GitHub
parent 5c117dd227
commit 052b2dfdc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 37 deletions

View file

@ -687,6 +687,16 @@ class PydocDocTest(unittest.TestCase):
finally:
pydoc.getpager = getpager_old
def test_namedtuple_fields(self):
Person = namedtuple('Person', ['nickname', 'firstname'])
with captured_stdout() as help_io:
pydoc.help(Person)
helptext = help_io.getvalue()
self.assertIn("nickname", helptext)
self.assertIn("firstname", helptext)
self.assertIn("Alias for field number 0", helptext)
self.assertIn("Alias for field number 1", helptext)
def test_namedtuple_public_underscore(self):
NT = namedtuple('NT', ['abc', 'def'], rename=True)
with captured_stdout() as help_io: