Skip to content

Commit

Permalink
test: Test string subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
igo95862 committed May 21, 2022
1 parent b1db762 commit 1a8ab05
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test_read_write_dbus_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,18 @@ def test_message_properties(self) -> None:
self.assertEqual(message.member,
'GetUnit')

def test_string_subclass(self) -> None:
from enum import Enum

class TestEnum(str, Enum):
SOMETHING = 'test'

message = create_message(self.bus)
message.append_data('s', TestEnum.SOMETHING)
message.seal()

self.assertEqual(message.get_contents(), TestEnum.SOMETHING)


if __name__ == "__main__":
main()

1 comment on commit 1a8ab05

@igo95862
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bernhardkaindl Looks like str subclasses work. class TestEnum(str, Enum): makes the new enum a subclass of str.

Please sign in to comment.