[rtems-central commit] content: Do not add gaps after blank lines
Sebastian Huber
sebh at rtems.org
Fri Sep 18 12:38:26 UTC 2020
Module: rtems-central
Branch: master
Commit: 38a6882e6fc9dca26ab68c0536c0c04b61fd0149
Changeset: http://git.rtems.org/rtems-central/commit/?id=38a6882e6fc9dca26ab68c0536c0c04b61fd0149
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Sep 18 14:32:18 2020 +0200
content: Do not add gaps after blank lines
---
rtemsspec/content.py | 2 ++
rtemsspec/tests/test_content.py | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
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():
More information about the vc
mailing list