https://github.com/python/cpython/commit/7b25a82e83ad8fe15e4302bb7655309573affa83
commit: 7b25a82e83ad8fe15e4302bb7655309573affa83
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-02-19T19:02:29+02:00
summary:
Fix test_compile with -O mode (GH-115346)
files:
M Lib/test/test_compile.py
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 4d8647be6a14f1..0126780982059a 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -749,7 +749,7 @@ def f():
return "unused"
self.assertEqual(f.__code__.co_consts,
- ("docstring", "used"))
+ (f.__doc__, "used"))
@support.cpython_only
def test_remove_unused_consts_no_docstring(self):
@@ -794,7 +794,7 @@ def test_strip_unused_None(self):
def f1():
"docstring"
return 42
- self.assertEqual(f1.__code__.co_consts, ("docstring", 42))
+ self.assertEqual(f1.__code__.co_consts, (f1.__doc__, 42))
# This is a regression test for a CPython specific peephole optimizer
# implementation bug present in a few releases. It's assertion verifies
@@ -1047,6 +1047,8 @@ def no_code2():
for func in (no_code1, no_code2):
with self.subTest(func=func):
+ if func is no_code1 and no_code1.__doc__ is None:
+ continue
code = func.__code__
[(start, end, line)] = code.co_lines()
self.assertEqual(start, 0)
@@ -1524,6 +1526,7 @@ def test_multiline_boolean_expression(self):
self.assertOpcodeSourcePositionIs(compiled_code, 'POP_JUMP_IF_TRUE',
line=4, end_line=4, column=8, end_column=13, occurrence=2)
+ @unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized
mode")
def test_multiline_assert(self):
snippet = textwrap.dedent("""\
assert (a > 0 and
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]