def test_storyerror_identify_unexpected_characters(patch, storyerror): patch.init(UnexpectedCharacters) patch.init(Intention) patch.object(Intention, 'is_function', return_value=True) patch.object(StoryError, 'get_line') storyerror.error = UnexpectedCharacters('seq', 'lex', 0, 0) assert storyerror.identify() == ErrorCodes.function_misspell
def test_storyerror_unexpected_characters_expected_block_before( patch, storyerror): patch.init(Intention) patch.object(Intention, 'is_function', return_value=False) patch.object(StoryError, 'is_valid_name_start', return_value=True) patch.object(Intention, 'unnecessary_colon', return_value=False) storyerror.error = UnexpectedCharacters(seq='abc', lex_pos=0, line=0, column=0, allowed=None) result = storyerror.unexpected_characters_code() assert result == ErrorCodes.block_expected_before
def test_storyerror_identify_unexpected_characters(patch, storyerror): patch.init(UnexpectedCharacters) patch.object(StoryError, 'unexpected_characters_code') storyerror.error = UnexpectedCharacters('seq', 'lex', 0, 0) assert storyerror.identify() == storyerror.unexpected_characters_code()
def test_storyerror_hint_invalid_character(patch, storyerror): storyerror.error = UnexpectedCharacters('seq', 0, line=1, column=5) storyerror.error_tuple = ErrorCodes.invalid_character storyerror._format = {'character': '$'} assert storyerror.hint() == '`$` is not allowed here'
def test_storyerror_identify_unexpected_characters(patch, storyerror): patch.init(UnexpectedCharacters) patch.object(StoryError, "unexpected_characters_code") storyerror.error = UnexpectedCharacters("seq", "lex", 0, 0) assert storyerror.identify() == storyerror.unexpected_characters_code()
def test_storyerror_hint_invalid_character(patch, storyerror): storyerror.error = UnexpectedCharacters("seq", 0, line=1, column=5) storyerror.error_tuple = ErrorCodes.invalid_character storyerror._format = {"character": "$"} assert storyerror.hint() == "`$` is not allowed here"