From 634cb1e7fdfbef3e2a30dfbd8a48e6bb5284d9b9 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 25 Aug 2020 07:57:49 -0500 Subject: [PATCH] Don't format comments in clean_comment As noted in https://github.com/dask/helm-chart/pull/92#discussion_r474597129, in some comments capitalization is important so frigate shouldn't change it. --- frigate/gen.py | 6 +++--- frigate/tests/test_frigate.py | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frigate/gen.py b/frigate/gen.py index a917e57..8621645 100644 --- a/frigate/gen.py +++ b/frigate/gen.py @@ -166,13 +166,13 @@ def get_comment(tree, key): def clean_comment(comment): """Remove comment formatting. - Strip a comment down and turn it into a standalone human readable sentence. + Strip a comment. Examples: Strip down a comment >>> clean_comment("# hello world") - "Hello world" + "hello world" Args: comment (str): Comment to clean @@ -181,7 +181,7 @@ def clean_comment(comment): str: Cleaned sentence """ - return comment.strip("# ").capitalize() + return comment.strip("# ") def traverse(tree, root=None): diff --git a/frigate/tests/test_frigate.py b/frigate/tests/test_frigate.py index ecd43b9..7d1c572 100644 --- a/frigate/tests/test_frigate.py +++ b/frigate/tests/test_frigate.py @@ -62,7 +62,7 @@ def test_get_comment(yaml): from frigate.gen import get_comment tree = yaml.load("hello: world # this is the comment") - assert get_comment(tree, "hello") == "This is the comment" + assert get_comment(tree, "hello") == "this is the comment" tree = yaml.load( """ @@ -71,7 +71,7 @@ def test_get_comment(yaml): # this is also not the comment """ ) - assert get_comment(tree, "hello") == "This is the comment" + assert get_comment(tree, "hello") == "this is the comment" tree = yaml.load( """ @@ -82,7 +82,7 @@ def test_get_comment(yaml): # this is also not the comment """ ) - assert get_comment(tree, "hello") == "This is the comment" + assert get_comment(tree, "hello") == "this is the comment" tree = yaml.load( """ @@ -94,7 +94,7 @@ def test_get_comment(yaml): # this is also not the comment """ ) - assert get_comment(tree, "hello") == "This is the comment" + assert get_comment(tree, "hello") == "this is the comment" tree = yaml.load( """ @@ -107,14 +107,17 @@ def test_get_comment(yaml): ) assert get_comment(tree, "hello") == "" + tree = yaml.load("hello: world # Use a `LoadBalancer`.") + assert get_comment(tree, "hello") == "Use a `LoadBalancer`." + def test_clean_comment(): from frigate.gen import clean_comment - assert clean_comment("# hello world") == "Hello world" - assert clean_comment("hello world") == "Hello world" - assert clean_comment("## # ## ## hello world") == "Hello world" - assert clean_comment(" # hello world ") == "Hello world" + assert clean_comment("# hello world") == "hello world" + assert clean_comment("hello world") == "hello world" + assert clean_comment("## # ## ## hello world") == "hello world" + assert clean_comment(" # hello world ") == "hello world" def test_traversal(simple_chart, rich_chart): @@ -129,7 +132,7 @@ def test_traversal(simple_chart, rich_chart): assert [ "replicaCount", - "Number of nginx pod replicas to create", + "number of nginx pod replicas to create", "1", ] in rich_output