From 8b065d2e57be2aeb8cfac845c098bf8b33604b46 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Fri, 5 Jul 2019 11:45:12 +0300 Subject: [PATCH] Fix unwanted AttributeError in messagetypes --- src/messagetypes/message.py | 2 +- src/tests/core.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/messagetypes/message.py b/src/messagetypes/message.py index ab61e375..f52c6b35 100644 --- a/src/messagetypes/message.py +++ b/src/messagetypes/message.py @@ -23,7 +23,7 @@ class Message(MsgBase): self.data["subject"] = data["subject"] self.data["body"] = data["body"] except KeyError as e: - logger.error("Missing key %s", e.name) + logger.error("Missing key %s", e) return self.data def process(self): diff --git a/src/tests/core.py b/src/tests/core.py index 5706f04b..ce8e7877 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -70,6 +70,14 @@ class TestCore(unittest.TestCase): self.assertEqual(msg_data['subject'], obj3e.subject) self.assertEqual(msg_data['body'], obj3e.body) + try: + MsgEncode({'body': 'A msg with no subject'}, 3) + except Exception as e: + self.fail( + 'Exception %s whyle trying to encode message' + ' with no subject!' % e + ) + def _wipe_knownnodes(self): with knownnodes.knownNodesLock: knownnodes.knownNodes = {stream: {} for stream in range(1, 4)}