diff --git a/tavern/_plugins/mqtt/response.py b/tavern/_plugins/mqtt/response.py index 71c29702..02bf55d1 100644 --- a/tavern/_plugins/mqtt/response.py +++ b/tavern/_plugins/mqtt/response.py @@ -181,11 +181,12 @@ def addwarning(w, *args, **kwargs): self._maybe_run_validate_functions(msg) else: - self._adderr( - "Expected '%s' on topic '%s' but no such message received", - expected_payload, - topic, - ) + if not self.expected.get("unexpected"): + self._adderr( + "Expected '%s' on topic '%s' but no such message received", + expected_payload, + topic, + ) if self.errors: if warnings: @@ -198,6 +199,9 @@ def addwarning(w, *args, **kwargs): saved = {} + if not msg: + return saved + saved.update(self.maybe_get_save_values_from_save_block("json", msg.payload)) saved.update(self.maybe_get_save_values_from_ext(msg, self.expected))