Skip to content

Commit dd84cd3

Browse files
committed
Add test for preserving indentation in annotate
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
1 parent c435d8c commit dd84cd3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_header.py

+19
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,25 @@ def test_find_and_replace_verbatim_no_newline():
304304
assert find_and_replace_header(text, info) == text
305305

306306

307+
def test_find_and_replace_preserve_indentation():
308+
"""If the first thing in a file is indented, do not change that thing's
309+
indentation.
310+
"""
311+
info = ReuseInfo({"GPL-3.0-or-later"}, {"SPDX-FileCopyrightText: Jane Doe"})
312+
text = ' # Hello\n print("world")'
313+
314+
assert find_and_replace_header(text, info) == cleandoc(
315+
"""
316+
# SPDX-FileCopyrightText: Jane Doe
317+
#
318+
# SPDX-License-Identifier: GPL-3.0-or-later
319+
320+
# Hello
321+
print("world")
322+
"""
323+
)
324+
325+
307326
def test_find_and_replace_newline_before_header():
308327
"""In a scenario where the header is preceded by whitespace, remove the
309328
preceding whitespace.

0 commit comments

Comments
 (0)