Skip to content

Commit 89987da

Browse files
committed
add class docstring test
1 parent e4953d9 commit 89987da

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Lib/test/test_code.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@
178178
nlocals: 3
179179
flags: 3
180180
consts: ("'hello'", "'world'")
181+
182+
>>> class class_with_docstring:
183+
... '''This is a docstring for class'''
184+
... pass
185+
186+
>>> print(class_with_docstring.__doc__)
187+
This is a docstring for class
188+
189+
>>> class class_without_docstring:
190+
... pass
191+
192+
>>> print(class_without_docstring.__doc__)
193+
None
181194
"""
182195

183196
import copy

Lib/test/test_compile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def test_lambda_doc(self):
344344
def test_lambda_consts(self):
345345
l = lambda: "this is the only const"
346346
self.assertEqual(len(l.__code__.co_consts), 1)
347+
self.assertEqual(l.__code__.co_consts[0], "this is the only const")
347348

348349
def test_encoding(self):
349350
code = b'# -*- coding: badencoding -*-\npass\n'

0 commit comments

Comments
 (0)