diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-11-21 11:13:15 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-11-21 11:15:24 +0100 |
commit | f1b569ec4b5b3d8dc47396018fef675d2e1dd11f (patch) | |
tree | 9c12dfa2397b3123fc1ff3c5e1f9e7209a67c06a | |
parent | content: Make Content iterable (diff) | |
download | rtems-central-f1b569ec4b5b3d8dc47396018fef675d2e1dd11f.tar.bz2 |
content: Improve empty list support
-rw-r--r-- | rtemsspec/content.py | 6 | ||||
-rw-r--r-- | rtemsspec/tests/test_content.py | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py index 7e596a2e..cd122f0b 100644 --- a/rtemsspec/content.py +++ b/rtemsspec/content.py @@ -467,7 +467,9 @@ class Content: items: GenericContentIterable, prologue: Optional[GenericContent] = None, epilogue: Optional[GenericContent] = None, - add_blank_line: bool = False) -> None: + add_blank_line: bool = False, + empty: Optional[GenericContent] = None) -> None: + # pylint: disable=too-many-arguments """ Adds a list with introduction. """ if items: self.wrap(prologue) @@ -476,6 +478,8 @@ class Content: if add_blank_line: self.add_blank_line() self.wrap(epilogue) + else: + self.wrap(empty) def open_list_item(self, content: GenericContent) -> None: """ Opens a list item. """ diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py index ad26972e..dbbd1564 100644 --- a/rtemsspec/tests/test_content.py +++ b/rtemsspec/tests/test_content.py @@ -218,6 +218,13 @@ def test_add_blank_line(): """ +def test_add_list_empty(): + content = Content("BSD-2-Clause", True) + content.add_list([], empty="empty") + assert str(content) == """empty +""" + + def test_ensure_blank_line(): content = Content("BSD-2-Clause", True) content.ensure_blank_line() |