'Verifies that test\'s status and message are as expected.
Expected status and message can be given as parameters. If expected
status is not given, expected status and message are read from test\'s
documentation. If documentation doesn\'t contain any of PASS, FAIL or
ERROR, test\'s status is expected to be PASS. If status is given that is
used. Expected message is documentation after given status. Expected
message can also be regular expression. In that case expected match
starts with REGEXP: , which is ignored in the regexp match.'

def _check_test_status(self, test, status=None, message=None):

    if (status is not None):
        test.exp_status = status
    if (message is not None):
        test.exp_message = message
    if (test.exp_status != test.status):
        if (test.exp_status == 'PASS'):
            msg = 'Test    was    expected    to    PASS    but    it    FAILED.    '
            msg += ('Error    message:\n' + test.message)
        else:
            msg = 'Test    was    expected    to    FAIL    but    it    PASSED.    '
            msg += ('Expected    message:\n' + test.exp_message)
        raise AssertionError(msg)
    if (test.exp_message == test.message):
        return
    if test.exp_message.startswith('REGEXP:'):
        pattern = test.exp_message.replace('REGEXP:', '', 1).strip()
        if re.match(('^%s$' % pattern), test.message, re.DOTALL):
            return
    if test.exp_message.startswith('GLOB:'):
        pattern = test.exp_message.replace('GLOB:', '', 1).strip()
        matcher = utils.Matcher(pattern, caseless=False, spaceless=False)
        if matcher.match(test.message):
            return
    if test.exp_message.startswith('STARTS:'):
        start = test.exp_message.replace('STARTS:', '', 1).strip()
        if (not start):
            raise RuntimeError("Empty    'STARTS:'    is    not    allowed")
        if test.message.startswith(start):
            return
    raise AssertionError(('Wrong    message\n\nExpected:\n%s\n\nActual:\n%s\n' % (test.exp_message, test.message)))
