From af848eb3d219414abf9129d341d355d10cdaa376 Mon Sep 17 00:00:00 2001 From: Marko Durkovic Date: Mon, 8 Nov 2021 15:11:39 +0100 Subject: [PATCH] Parse empty msg definitions --- src/rosbags/typesys/msg.py | 2 +- tests/test_parse.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rosbags/typesys/msg.py b/src/rosbags/typesys/msg.py index 9eda4e46..d47626db 100644 --- a/src/rosbags/typesys/msg.py +++ b/src/rosbags/typesys/msg.py @@ -30,7 +30,7 @@ specification = msgdef (msgsep msgdef)* msgdef - = r'MSG:\s' scoped_name definition+ + = r'MSG:\s' scoped_name definition* msgsep = r'================================================================================' diff --git a/tests/test_parse.py b/tests/test_parse.py index 00783d91..59083b3e 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -118,10 +118,16 @@ module test_msgs { """ +def test_parse_empty_msg(): + """Test msg parser with empty message.""" + ret = get_types_from_msg('', 'std_msgs/msg/Empty') + assert ret == {'std_msgs/msg/Empty': ([], [])} + + def test_parse_msg(): """Test msg parser.""" with pytest.raises(TypesysError, match='Could not parse'): - get_types_from_msg('', 'test_msgs/msg/Foo') + get_types_from_msg('invalid', 'test_msgs/msg/Foo') ret = get_types_from_msg(MSG, 'test_msgs/msg/Foo') assert 'test_msgs/msg/Foo' in ret consts, fields = ret['test_msgs/msg/Foo']