Skip to content

Commit 7db42a1

Browse files
committed
add docstring test under -OO
1 parent 92d1d16 commit 7db42a1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Lib/test/test_code.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,33 @@ def f():
868868
3 * [(42, 42, None, None)],
869869
)
870870

871+
@cpython_only
872+
def test_docstring_under_o2(self):
873+
code = textwrap.dedent('''
874+
def has_docstring(x, y):
875+
"""This is a first-line doc string"""
876+
"""This is a second-line doc string"""
877+
a = x + y
878+
b = x - y
879+
return a, b
880+
881+
882+
def no_docstring(x):
883+
def g(y):
884+
return x + y
885+
return g
886+
887+
888+
async def async_func():
889+
"""asynf function doc string"""
890+
pass
891+
892+
893+
for func in [has_docstring, no_docstring(4), async_func]:
894+
assert(func.__doc__ is None)
895+
''')
896+
897+
rc, out, err = assert_python_ok('-OO', '-c', code)
871898

872899
if check_impl_detail(cpython=True) and ctypes is not None:
873900
py = ctypes.pythonapi

0 commit comments

Comments
 (0)