diff --git a/amqtt/plugins/logging.py b/amqtt/plugins/logging.py index 1c6ef18..bc44723 100644 --- a/amqtt/plugins/logging.py +++ b/amqtt/plugins/logging.py @@ -19,7 +19,7 @@ class EventLoggerPlugin: def __getattr__(self, name): if name.startswith("on_"): return partial(self.log_event, event_name=name) - raise AttributeError + raise AttributeError(f"'EventLoggerPlugin' object has no attribute {name!r}") class PacketLoggerPlugin: diff --git a/tests/plugins/test_logging.py b/tests/plugins/test_logging.py new file mode 100644 index 0000000..5fef6a8 --- /dev/null +++ b/tests/plugins/test_logging.py @@ -0,0 +1,11 @@ +import pytest + +import amqtt.plugins.logging + + +def test_EventLoggerPlugin_getattr(): + logger = amqtt.plugins.logging.EventLoggerPlugin(None) + with pytest.raises(AttributeError) as exc: + logger.foo + + assert "foo" in str(exc.value)