From 0d806eeb6e37d02283e3ea9d10c47e80ce378244 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 27 Feb 2021 20:51:48 +0100 Subject: [PATCH] - Removed setUp method from test_event_parse - let the parent setUp run and properly start the daemon - More resilient logic in case some entries in the Zeroconf registry are still loading and the info object is still None --- platypush/plugins/zeroconf.py | 2 +- tests/test_event_parse.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/platypush/plugins/zeroconf.py b/platypush/plugins/zeroconf.py index c136a4537f..cdbc30e429 100644 --- a/platypush/plugins/zeroconf.py +++ b/platypush/plugins/zeroconf.py @@ -25,7 +25,7 @@ class ZeroconfListener(zeroconf.ServiceListener): @staticmethod def parse_service_info(info: ServiceInfo) -> dict: return { - 'addresses': [socket.inet_ntoa(addr) for addr in info.addresses], + 'addresses': [socket.inet_ntoa(addr) for addr in info.addresses if info and info.addresses], 'port': info.port, 'host_ttl': info.host_ttl, 'other_ttl': info.other_ttl, diff --git a/tests/test_event_parse.py b/tests/test_event_parse.py index 12ce5c9e0f..4291ddf4fd 100644 --- a/tests/test_event_parse.py +++ b/tests/test_event_parse.py @@ -9,12 +9,10 @@ from . import BaseTest, conf_dir class TestEventParse(BaseTest): config_file = os.path.join(conf_dir, 'test_http_config.yaml') - - def setUp(self): - self.condition = EventCondition.build({ - 'type': 'platypush.message.event.ping.PingEvent', - 'message': 'This is (the)? answer: ${answer}' - }) + condition = EventCondition.build({ + 'type': 'platypush.message.event.ping.PingEvent', + 'message': 'This is (the)? answer: ${answer}' + }) def test_event_parse(self): message = "GARBAGE GARBAGE this is the answer: 42"