summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-18 14:32:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-09-18 14:36:34 +0200
commit38a6882e6fc9dca26ab68c0536c0c04b61fd0149 (patch)
tree02b62d2d7d5c52bba041bfcd97387d64ac6b0e86
parentc172dc0426abe75ba4300be30578e16925cb0f9b (diff)
downloadrtems-central-38a6882e6fc9dca26ab68c0536c0c04b61fd0149.tar.bz2
content: Do not add gaps after blank lines
-rw-r--r--rtemsspec/content.py2
-rw-r--r--rtemsspec/tests/test_content.py26
2 files changed, 28 insertions, 0 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 3a25b7e..ee7b2b3 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -385,11 +385,13 @@ class Content:
def add_blank_line(self):
""" Adds a blank line. """
self._lines.append("")
+ self._gap = False
def ensure_blank_line(self):
""" Ensures that the last line is blank. """
if not self._lines or self._lines[-1]:
self._lines.append("")
+ self._gap = False
def register_license(self, the_license: str) -> None:
""" Registers a licence for the content. """
diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py
index 8383ca8..123128d 100644
--- a/rtemsspec/tests/test_content.py
+++ b/rtemsspec/tests/test_content.py
@@ -89,6 +89,32 @@ def test_add():
b
c
"""
+ content = Content("BSD-2-Clause", True)
+ content.add("a")
+ assert str(content) == """a
+"""
+ content.add_blank_line()
+ assert str(content) == """a
+
+"""
+ content.add("b")
+ assert str(content) == """a
+
+b
+"""
+ content = Content("BSD-2-Clause", True)
+ content.add("a")
+ assert str(content) == """a
+"""
+ content.ensure_blank_line()
+ assert str(content) == """a
+
+"""
+ content.add("b")
+ assert str(content) == """a
+
+b
+"""
def test_wrap():