mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-105724: Add location information to assert
errors (GH-105935)
This commit is contained in:
parent
fd9d70a94d
commit
bdd8ddfda1
4 changed files with 124 additions and 6 deletions
|
@ -1315,18 +1315,18 @@ class TestSourcePositions(unittest.TestCase):
|
|||
snippet = textwrap.dedent("""\
|
||||
assert (a > 0 and
|
||||
bb > 0 and
|
||||
ccc == 4), "error msg"
|
||||
ccc == 1000000), "error msg"
|
||||
""")
|
||||
compiled_code, _ = self.check_positions_against_ast(snippet)
|
||||
self.assertOpcodeSourcePositionIs(compiled_code, 'LOAD_ASSERTION_ERROR',
|
||||
line=1, end_line=3, column=0, end_column=30, occurrence=1)
|
||||
line=1, end_line=3, column=0, end_column=36, occurrence=1)
|
||||
# The "error msg":
|
||||
self.assertOpcodeSourcePositionIs(compiled_code, 'LOAD_CONST',
|
||||
line=3, end_line=3, column=19, end_column=30, occurrence=4)
|
||||
line=3, end_line=3, column=25, end_column=36, occurrence=4)
|
||||
self.assertOpcodeSourcePositionIs(compiled_code, 'CALL',
|
||||
line=1, end_line=3, column=0, end_column=30, occurrence=1)
|
||||
line=1, end_line=3, column=0, end_column=36, occurrence=1)
|
||||
self.assertOpcodeSourcePositionIs(compiled_code, 'RAISE_VARARGS',
|
||||
line=1, end_line=3, column=0, end_column=30, occurrence=1)
|
||||
line=1, end_line=3, column=8, end_column=22, occurrence=1)
|
||||
|
||||
def test_multiline_generator_expression(self):
|
||||
snippet = textwrap.dedent("""\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue