From 3a1b5a79a099e59d018c2a8491acfe435b9760b4 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 14 Mar 2024 15:38:55 -0500 Subject: [PATCH] Remove trailing newline --- conda_build/metadata.py | 2 +- tests/test_metadata.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 211023817e..211721b10e 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -325,7 +325,7 @@ def select_lines(text: str, namespace: dict[str, Any], variants_in_place: bool) f"exception:\n" f"{e.__class__.__name__}: {e}\n" ) - return "\n".join(lines) + "\n" + return "\n".join(lines) def yamlize(data): diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 1cee42432a..305ea0e51d 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -57,14 +57,14 @@ def test_uses_vcs_in_metadata(testing_workdir, testing_metadata): def test_select_lines(): lines = "\n".join( ( - "", + "", # preserve leading newline "test", "test [abc] no", "test [abc] # no", " ' test ' ", ' " test " ', - "", - "# comment line", + "", # preserve newline + "# comment line", # preserve comment line (not comment) "test [abc]", " 'quoted # [abc] '", ' "quoted # [abc] yes "', @@ -74,20 +74,20 @@ def test_select_lines(): "test {{ JINJA_VAR[:2] }} # stuff yes [abc]", "test {{ JINJA_VAR[:2] }} # [abc] stuff yes", '{{ environ["test"] }} # [abc]', - "", # trailing newline + "", # trailing newline is lost ) ) assert select_lines(lines, {"abc": True}, variants_in_place=True) == "\n".join( ( - "", + "", # preserve leading newline "test", "test [abc] no", "test [abc] # no", " ' test '", ' " test "', - "", - "", + "", # preserve newline + "", # preserve comment line (not comment) "test", " 'quoted'", ' "quoted"', @@ -97,21 +97,21 @@ def test_select_lines(): "test {{ JINJA_VAR[:2] }}", "test {{ JINJA_VAR[:2] }}", '{{ environ["test"] }}', - "", # trailing newline + # trailing newline is lost ) ) assert select_lines(lines, {"abc": False}, variants_in_place=True) == "\n".join( ( - "", + "", # preserve leading newline "test", "test [abc] no", "test [abc] # no", " ' test '", ' " test "', - "", - "", + "", # preserve newline + "", # preserve comment line (not comment) "test {{ JINJA_VAR[:2] }}", - "", # trailing newline + # trailing newline is lost ) ) @@ -155,7 +155,7 @@ def test_select_lines_battery(): ) * 10 ) - selection = "\n".join(selection) + "\n" # trailing newline + selection = "\n".join(selection) assert select_lines(lines, namespace, variants_in_place=True) == selection