Skip to content

Commit

Permalink
Use yaml FullLoader that handle UUID type as well
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jan 30, 2025
1 parent eca3ae3 commit 723ee36
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/rmq/test_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
from . import RmqCoordinator
from .. import utils

def uuid_representer(dumper, data):
return dumper.represent_scalar(u'!uuid', str(data))

def uuid_constructor(loader, node):
value = loader.construct_scalar(node)
return uuid.UUID(value)

yaml.add_representer(uuid.UUID, uuid_representer)
yaml.add_constructor(u'!uuid', uuid_constructor)

@pytest.fixture
def persister():
Expand All @@ -41,7 +50,8 @@ def _coordinator():
message_exchange=message_exchange,
task_exchange=task_exchange,
task_queue=task_queue,
decoder=functools.partial(yaml.load, Loader=yaml.Loader),
encoder=functools.partial(yaml.dump, encoding='utf-8'),
decoder=functools.partial(yaml.load, Loader=yaml.FullLoader),
)

loop = asyncio.get_event_loop()
Expand Down

0 comments on commit 723ee36

Please sign in to comment.