def check_errors(string, messages): errors = Errors() try: list(_tokenize(string, errors)) except TokenizerError: errors_set = {(e.message, e.location.start.offset, e.location.end.offset) for e in errors.list} for error in messages: assert error in errors_set else: raise AssertionError('No errors')
def check_errors(string, messages): errors = Errors() try: list(_tokenize(string, errors)) except TokenizerError: errors_set = { (e.message, e.location.start.offset, e.location.end.offset) for e in errors.list } for error in messages: assert error in errors_set else: raise AssertionError('No errors')
def tokenize(src, errors=None): src = dedent(src).strip() return _tokenize(src, errors)