Skip to content

Commit

Permalink
Remove trailing newline
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Mar 15, 2024
1 parent 56d6343 commit 60783ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
26 changes: 13 additions & 13 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "',
Expand All @@ -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"',
Expand All @@ -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
)
)

Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 60783ee

Please sign in to comment.