def test_model(self): model = get_model('''\ *** Invalid *** *** Settings *** Invalid Documentation ''', data_only=True) inv_header = ( "Unrecognized section header '*** Invalid ***'. Valid sections: " "'Settings', 'Variables', 'Test Cases', 'Tasks', 'Keywords' and 'Comments'." ) inv_setting = "Non-existing setting 'Invalid'." expected = File([ CommentSection( body=[ Error([Token('ERROR', '*** Invalid ***', 1, 0, inv_header)]) ] ), SettingSection( header=SectionHeader([ Token('SETTING HEADER', '*** Settings ***', 2, 0) ]), body=[ Error([Token('ERROR', 'Invalid', 3, 0, inv_setting)]), Documentation([Token('DOCUMENTATION', 'Documentation', 4, 0)]) ] ) ]) assert_model(model, expected)
def test_model_error_with_error_and_fatal_error(self): model = get_resource_model('''\ *** Invalid *** *** Settings *** Invalid Documentation *** Test Cases *** ''', data_only=True) inv_header = ( "Unrecognized section header '*** Invalid ***'. Valid sections: " "'Settings', 'Variables', 'Keywords' and 'Comments'.") inv_setting = "Non-existing setting 'Invalid'." inv_testcases = "Resource file with 'Test Cases' section is invalid." expected = File([ CommentSection(body=[ Error([Token('ERROR', '*** Invalid ***', 1, 0, inv_header)]) ]), SettingSection( header=SectionHeader( [Token('SETTING HEADER', '*** Settings ***', 2, 0)]), body=[ Error([Token('ERROR', 'Invalid', 3, 0, inv_setting)]), Documentation( [Token('DOCUMENTATION', 'Documentation', 4, 0)]), Error([ Token('FATAL ERROR', '*** Test Cases ***', 5, 0, inv_testcases) ]) ]) ]) assert_model(model, expected)
def test_model_error_with_fatal_error(self): model = get_resource_model('''\ *** Test Cases *** ''', data_only=True) inv_testcases = "Resource file with 'Test Cases' section is invalid." expected = File([ CommentSection( body=[ Error([Token('FATAL ERROR', '*** Test Cases ***', 1, 0, inv_testcases)]) ] ) ]) assert_model(model, expected)
Example # Comment Keyword arg ...\targh \t\t *** Keywords *** # Comment continues Keyword [Arguments] ${arg1} ${arg2} Log Got ${arg1} and ${arg}! ''' PATH = os.path.join( os.getenv('TEMPDIR') or tempfile.gettempdir(), 'test_model.robot') EXPECTED = File(sections=[ CommentSection(body=[EmptyLine([Token('EOL', '\n', 1, 0)])]), TestCaseSection(header=TestCaseSectionHeader([ Token('TESTCASE_HEADER', '*** Test Cases ***', 2, 0), Token('EOL', '\n', 2, 18) ]), body=[ EmptyLine([Token('EOL', '\n', 3, 0)]), TestCase(header=TestCaseName([ Token('TESTCASE_NAME', 'Example', 4, 0), Token('EOL', '\n', 4, 7) ]), body=[ Comment([ Token('SEPARATOR', ' ', 5, 0), Token('COMMENT', '# Comment', 5, 2), Token('EOL', '\n', 5, 11),