def __str__(self) -> str: output = '{} at {}'.format(self.__message, self.__span) if self.__span is None: return output lines = highlight(self.__span) return '{}\n{}'.format(output, lines)
def test_highlight_partial_three_lines(self): source = 'hello\ngreen\nworld' span = SourceSpan(source, Position(0, 1, 3), Position(len(source) - 3, 3, 4)) result = highlight(span) assert result == '1. hello\n ~~~\n2. green\n ~~~~~\n3. world\n ~~~'
def test_highlight_two_lines(self): source = 'hello\nworld' span = SourceSpan(source, Position.initial(), Position(len(source) - 1, 2, 6)) result = highlight(span) assert result == '1. hello\n ~~~~~\n2. world\n ~~~~~'
def test_highlight_single_line(self): source = 'hello world' span = SourceSpan(source, Position.initial(), Position(len(source) - 1, 1, len(source) + 1)) result = highlight(span) assert result == '1. hello world\n ~~~~~~~~~~~'
def test_highlight_partial_single_line(self): source = 'hello world' span = SourceSpan(source, Position(0, 1, 4), Position(len(source) - 3, 1, len(source) - 1)) result = highlight(span) assert result == '1. hello world\n ~~~~~~'
def __str__(self) -> str: return '{} (expected {} but got {} at {})\n{}'.format(self.__message, self.__expected_type, self.token.type, self.token.span, highlight(self.token.span))
def __str__(self) -> str: return '{} ({} at {})\n{}'.format(self.__message, self.__token.type, self.token.span, highlight(self.token.span))