| 976 | |
| 977 | @support.cpython_only |
| 978 | def test_docstring_omitted(self): |
| 979 | # See gh-115347 |
| 980 | src = textwrap.dedent(""" |
| 981 | def f(): |
| 982 | "docstring1" |
| 983 | def h(): |
| 984 | "docstring2" |
| 985 | return 42 |
| 986 | |
| 987 | class C: |
| 988 | "docstring3" |
| 989 | pass |
| 990 | |
| 991 | return h |
| 992 | """) |
| 993 | for opt in [-1, 0, 1, 2]: |
| 994 | for mode in ["exec", "single"]: |
| 995 | with self.subTest(opt=opt, mode=mode): |
| 996 | code = compile(src, "<test>", mode, optimize=opt) |
| 997 | output = io.StringIO() |
| 998 | with contextlib.redirect_stdout(output): |
| 999 | dis.dis(code) |
| 1000 | self.assertNotIn('NOP', output.getvalue()) |
| 1001 | |
| 1002 | @unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: unable to find constant -0.0 in (0.0,) |
| 1003 | def test_dont_merge_constants(self): |