diff --git a/CHANGELOG.md b/CHANGELOG.md index df854ec..87aaa5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Fixed bug failing to get a `str` representation of `Message` on `ipy` + ### Removed diff --git a/src/compas_eve/core.py b/src/compas_eve/core.py index 33baba1..0c80545 100644 --- a/src/compas_eve/core.py +++ b/src/compas_eve/core.py @@ -50,8 +50,11 @@ class Message(UserDict): A message is fundamentally a dictionary and behaves as one.""" + def __str__(self): + return str(self.data) + def __getattr__(self, name): - return self.data[name] + return self.__dict__["data"][name] @classmethod def parse(cls, value): diff --git a/tests/unit/test_core.py b/tests/unit/test_core.py index 11df6a0..df87139 100644 --- a/tests/unit/test_core.py +++ b/tests/unit/test_core.py @@ -99,3 +99,8 @@ def callback(msg): assert received, "Message not received" assert result["value"].name == "Jazz" assert result["value"].hello_name == "Hello Jazz" + + +def test_message_str(): + msg = Message(a=3) + assert str(msg) == "{'a': 3}"