diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2019-08-10 13:16:20 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-10 11:14:38 +0200 |
commit | 3981bec0d1edc0cfc0ff8fc67b42038735e25fe4 (patch) | |
tree | 2daf0f7e0053dc79652986f596a876ed5263e08e /tests/message | |
parent | fb81d1ade4f0c87039c828f9aed94469691d825d (diff) | |
download | pylint-git-3981bec0d1edc0cfc0ff8fc67b42038735e25fe4.tar.gz |
[tests.message] Add a test for multiple messages with the same old name
Diffstat (limited to 'tests/message')
-rw-r--r-- | tests/message/unittest_message_definition_store.py | 33 | ||||
-rw-r--r-- | tests/message/unittest_message_id_store.py | 20 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/message/unittest_message_definition_store.py b/tests/message/unittest_message_definition_store.py index 3a4ebf349..0af2c9b30 100644 --- a/tests/message/unittest_message_definition_store.py +++ b/tests/message/unittest_message_definition_store.py @@ -234,3 +234,36 @@ class TestMessageDefinitionStore(object): def test_renamed_message_register(self, store): assert "msg-symbol" == store.get_message_definitions("W0001")[0].symbol assert "msg-symbol" == store.get_message_definitions("old-symbol")[0].symbol + + +def test_multiple_child_of_old_name(store): + """ We can define multiple name with the same old name. """ + + class FamillyChecker(BaseChecker): + name = "famillychecker" + msgs = { + "W1235": ( + "Child 1", + "child-one", + "Child one description.", + {"old_names": [("C1234", "mother")]}, + ), + "W1236": ( + "Child 2", + "child-two", + "Child two description", + {"old_names": [("C1234", "mother")]}, + ), + } + + store.register_messages_from_checker(FamillyChecker()) + mother = store.get_message_definitions("C1234") + child = store.get_message_definitions("W1235") + other_child = store.get_message_definitions("W1236") + assert len(mother) == 2 + assert len(child) == 1 + assert len(other_child) == 1 + child = child[0] + other_child = other_child[0] + assert child in mother + assert other_child in mother diff --git a/tests/message/unittest_message_id_store.py b/tests/message/unittest_message_id_store.py index 00fbd7028..dc2723b34 100644 --- a/tests/message/unittest_message_id_store.py +++ b/tests/message/unittest_message_id_store.py @@ -52,6 +52,26 @@ def test_register_message_definitions(empty_msgid_store, message_definitions): assert len(empty_msgid_store) == number_of_msgid +def test_add_msgid_and_symbol(empty_msgid_store): + empty_msgid_store.add_msgid_and_symbol("E1235", "new-sckiil") + empty_msgid_store.add_legacy_msgid_and_symbol("C1235", "old-sckiil", "E1235") + assert len(empty_msgid_store) == 2 + message_ids = empty_msgid_store.get_active_msgids("E1235") + assert len(message_ids) == 1 + assert message_ids[0] == "E1235" + message_ids = empty_msgid_store.get_active_msgids("old-sckiil") + assert len(message_ids) == 1 + assert message_ids[0] == "E1235" + assert empty_msgid_store.get_symbol("C1235") == "old-sckiil" + assert empty_msgid_store.get_symbol("E1235") == "new-sckiil" + assert empty_msgid_store.get_msgid("old-sckiil") == "C1235" + assert empty_msgid_store.get_msgid("new-sckiil") == "E1235" + with pytest.raises(KeyError) as e: + empty_msgid_store.get_symbol("C1234") + with pytest.raises(KeyError) as e: + empty_msgid_store.get_msgid("not-exist") + + def test_duplicate_symbol(empty_msgid_store): empty_msgid_store.add_msgid_and_symbol("W1234", "warning-symbol") with pytest.raises(InvalidMessageError) as error: |