Beispiel #1
0
 def assert_with_fail_msg(msg: MessageDefinition,
                          expected: bool = True) -> None:
     fail_msg = (
         f"With minversion='{msg.minversion}' and maxversion='{msg.maxversion}',"
         f" and the python interpreter being {sys.version_info} "
         "the message should{}be emitable")
     if expected:
         assert msg.may_be_emitted(), fail_msg.format(" ")
     else:
         assert not msg.may_be_emitted(), fail_msg.format(" not ")
def test_create_invalid_message_type(msgid, expected):
    checker_mock = mock.Mock(name="Checker")
    checker_mock.name = "checker"

    with pytest.raises(InvalidMessageError) as invalid_message_error:
        MessageDefinition.check_msgid(msgid)
    with pytest.raises(InvalidMessageError) as other_invalid_message_error:
        MessageDefinition(checker_mock, msgid, "msg", "descr", "symbol", "scope")
    assert str(invalid_message_error.value) == expected
    assert str(other_invalid_message_error.value) == expected
Beispiel #3
0
 def get_message_definition() -> MessageDefinition:
     return MessageDefinition(
         FalseChecker(),
         "W1234",
         "message",
         "description",
         "msg-symbol",
         WarningScope.NODE,
     )
Beispiel #4
0
 def get_message_definition():
     args = [
         FalseChecker(),
         "W1234",
         "message",
         "description",
         "msg-symbol",
         WarningScope.NODE,
     ]
     kwargs = {"minversion": None, "maxversion": None}
     return MessageDefinition(*args, **kwargs)
def test_create_invalid_message_type(msgid, expected):
    with pytest.raises(InvalidMessageError) as cm:
        MessageDefinition("checker", msgid, "msg", "descr", "symbol", "scope")
    assert str(cm.value) == expected
Beispiel #6
0
 def _compare_messages(
     desc: str, msg: MessageDefinition, checkerref: bool = False
 ) -> None:
     assert desc == msg.format_help(checkerref=checkerref)