def test_syntax_warning():
# exceed the 4 extra lines which are normally checked
with pytest.warns(SyntaxWarning) as warning_checker:
v = debug.format(
abs(
abs(
abs(
abs(
-1
)
)
)
)
)
assert len(warning_checker) == 1
warning = warning_checker.list[0]
print(warning.message)
assert 'Error: unexpected EOF while parsing (test_expr_render.py' in str(warning.message)
# check only the original code is included in the warning
assert '-1\n"' in str(warning.message)
s = re.sub(':\d{2,}', ':<line no>', str(v))
assert (
'tests/test_expr_render.py:<line no> test_syntax_warning\n 1 (int)'
) == s
评论列表
文章目录