MCPcopy Index your code
hub / github.com/python/cpython / test_multiline_assert

Method test_multiline_assert

Lib/test/test_compile.py:2011–2026  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2009
2010 @unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
2011 def test_multiline_assert(self):
2012 snippet = textwrap.dedent("""\
2013 assert (a > 0 and
2014 bb > 0 and
2015 ccc == 1000000), "error msg"
2016 """)
2017 compiled_code, _ = self.check_positions_against_ast(snippet)
2018 self.assertOpcodeSourcePositionIs(compiled_code, 'LOAD_COMMON_CONSTANT',
2019 line=1, end_line=3, column=0, end_column=36, occurrence=1)
2020 # The "error msg":
2021 self.assertOpcodeSourcePositionIs(compiled_code, 'LOAD_CONST',
2022 line=3, end_line=3, column=25, end_column=36, occurrence=2)
2023 self.assertOpcodeSourcePositionIs(compiled_code, 'CALL',
2024 line=1, end_line=3, column=0, end_column=36, occurrence=1)
2025 self.assertOpcodeSourcePositionIs(compiled_code, 'RAISE_VARARGS',
2026 line=1, end_line=3, column=8, end_column=22, occurrence=1)
2027
2028 def test_multiline_generator_expression(self):
2029 snippet = textwrap.dedent("""\

Callers

nothing calls this directly

Calls 3

dedentMethod · 0.45

Tested by

no test coverage detected