kopia lustrzana https://github.com/Yakifo/amqtt
throw exception instance not class and add test
rodzic
d50c1e25c9
commit
d43b36f90c
|
@ -19,7 +19,7 @@ class EventLoggerPlugin:
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name.startswith("on_"):
|
if name.startswith("on_"):
|
||||||
return partial(self.log_event, event_name=name)
|
return partial(self.log_event, event_name=name)
|
||||||
raise AttributeError
|
raise AttributeError(f"'EventLoggerPlugin' object has no attribute {name!r}")
|
||||||
|
|
||||||
|
|
||||||
class PacketLoggerPlugin:
|
class PacketLoggerPlugin:
|
||||||
|
|
|
@ -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)
|
Ładowanie…
Reference in New Issue