示例#1
0
    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(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)
示例#3
0
 def test_get_errors_and_fatal_errors_from_tokens(self):
     assert_equal(Error([Token('ERROR', error='error'),
                         Token('ARGUMENT'),
                         Token('FATAL ERROR', error='fatal error')]).errors,
                  ('error', 'fatal error'))
     assert_equal(Error([Token('FATAL ERROR', error=e) for e in '0123456789']).errors,
                  tuple('0123456789'))
 def test_get_errors_from_tokens(self):
     assert_equal(Error([Token('ERROR', error='xxx')]).errors,
                  ('xxx',))
     assert_equal(Error([Token('ERROR', error='xxx'),
                         Token('ARGUMENT'),
                         Token('ERROR', error='yyy')]).errors,
                  ('xxx', 'yyy'))
     assert_equal(Error([Token('ERROR', error=e) for e in '0123456789']).errors,
                  tuple('0123456789'))
示例#5
0
 def test_set_errors_explicitly(self):
     error = Error([])
     error.errors = ('explicitly set', 'errors')
     assert_equal(error.errors, ('explicitly set', 'errors'))
     error.tokens = [
         Token('ERROR', error='normal error'),
         Token('FATAL ERROR', error='fatal error')
     ]
     assert_equal(
         error.errors,
         ('normal error', 'fatal error', 'explicitly set', 'errors'))
示例#6
0
    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)