Home - Summaries: (main) : (py3.11) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/interpreter/pyparser/test/apptest_parsestring.py::test_invalid_escape_syntax_error_span

def test_invalid_escape_syntax_error_span():
        # When -Werror promotes the SyntaxWarning to a SyntaxError, the
        # error should highlight the full string token, not just one character.
        # E.g. for '"""\q"""' (8 chars) the end offset must be start+8.
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('error', category=SyntaxWarning)
            with raises(SyntaxError) as excinfo:
                eval('"""\\q"""')
        assert not w
        exc = excinfo.value
        # offset is 1-based column of opening quote; end_offset covers
        # the full token '"""\q"""' (8 chars).
>       assert exc.end_offset - exc.offset == len('"""\\q"""')
E       (application-level) AssertionError: assert (8 != 1) == 8
E        +  where 8 = SyntaxError("invalid escape sequence '\\q'", ('<string>', 1, 1, '"""\\q"""', 1, 8)).end_offset
E        +  and   1 = SyntaxError("invalid escape sequence '\\q'", ('<string>', 1, 1, '"""\\q"""', 1, 8)).offset
E        +  and   8 = len('"""\\q"""')

interpreter/pyparser/test/apptest_parsestring.py:69: AssertionError
builder: own-macos-arm64 build #1271+
test: pypy/interpreter/pyparser/test/apptest_parsestring.py::test_invalid_escape_syntax_error_span