aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-24 10:34:18 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-24 10:34:18 +0100
commit4cdc3caa4b81ddf06af35ca00197caed45dc65ac (patch)
treea9f7cd69e7f6e689ae54698586019eec44217cfe
parente125e98b53f59fe0bd3adad16ed77fd94797f0bf (diff)
Avoid double # at the beginning of help comments.
-rw-r--r--lesana/collection.py4
-rw-r--r--tests/test_collection.py7
2 files changed, 6 insertions, 5 deletions
diff --git a/lesana/collection.py b/lesana/collection.py
index f877d31..d49512a 100644
--- a/lesana/collection.py
+++ b/lesana/collection.py
@@ -59,7 +59,7 @@ class Entry(object):
else:
data[name] = field.empty()
if field.field.get('help', None) is not None:
- comment = "# {name} ({type}): {help}\n".format(**field.field)
+ comment = "{name} ({type}): {help}\n".format(**field.field)
try:
data.yaml_set_comment_before_after_key(
key=name,
@@ -73,7 +73,7 @@ class Entry(object):
)
valid_values = field.field.get('values', [])
if valid_values:
- comment = "# {name} ({type}): {valid_values}".format(
+ comment = "{name} ({type}): {valid_values}".format(
valid_values="|".join(valid_values),
**field.field
)
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 1400f57..99a5517 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -48,9 +48,10 @@ class testEntries(unittest.TestCase):
entry_fname = os.path.join(self.basepath, new_entry.fname)
with open(entry_fname) as fp:
text = fp.read()
- self.assertIn('quantity (integer): how many items are there', text)
- self.assertIn('other (yaml):', text)
- self.assertNotIn('position (string)', text)
+ self.assertIn('# quantity (integer): how many items are there', text)
+ self.assertIn('# other (yaml):', text)
+ self.assertNotIn('# position (string)', text)
+ self.assertNotIn('# # other (yaml)', text)
written = ruamel.yaml.safe_load(text)
self.assertIsInstance(written['quantity'], int)
self.assertIsInstance(written['name'], str)