summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-03-25 20:01:13 (GMT)
committerGitHub <noreply@github.com>2019-03-25 20:01:13 (GMT)
commitd1e768a67707bf7bb426c1537e1a764e89eaff78 (patch)
treeeba1dc9c8a257e8c9fec36cef006eb06498d54ee /Lib/test/test_inspect.py
parent713a8ae7926472b02ee1a394633eb54aaa7912d1 (diff)
downloadcpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.zip
cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.gz
cpython-d1e768a67707bf7bb426c1537e1a764e89eaff78.tar.bz2
bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index b9072e0..bc675aa 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -375,6 +375,11 @@ class GetSourceBase(unittest.TestCase):
self.assertEqual(inspect.getsource(obj),
self.sourcerange(top, bottom))
+class SlotUser:
+ 'Docstrings for __slots__'
+ __slots__ = {'power': 'measured in kilowatts',
+ 'distance': 'measured in kilometers'}
+
class TestRetrievingSourceCode(GetSourceBase):
fodderModule = mod
@@ -429,6 +434,10 @@ class TestRetrievingSourceCode(GetSourceBase):
'A longer,\n\nindented\n\ndocstring.')
self.assertEqual(inspect.getdoc(git.abuse),
'Another\n\ndocstring\n\ncontaining\n\ntabs')
+ self.assertEqual(inspect.getdoc(SlotUser.power),
+ 'measured in kilowatts')
+ self.assertEqual(inspect.getdoc(SlotUser.distance),
+ 'measured in kilometers')
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")