Skip to content

Commit

Permalink
Add a test for --copyright-prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
  • Loading branch information
carmenbianca committed Jul 1, 2024
1 parent 5937afa commit dbfabbd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_main_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,45 @@ def test_annotate_no_year(fake_repository, stringio):
assert simple_file.read_text() == expected


@pytest.mark.parametrize(
"copyright_prefix", ["--copyright-prefix", "--copyright-style"]
)
def test_annotate_copyright_prefix(
fake_repository, copyright_prefix, stringio, mock_date_today
):
"""Add a header with a specific copyright prefix. Also test the old name of
the parameter.
"""
simple_file = fake_repository / "foo.py"
simple_file.write_text("pass")
expected = cleandoc(
"""
# Copyright 2018 Jane Doe
#
# SPDX-License-Identifier: GPL-3.0-or-later
pass
"""
)

result = main(
[
"annotate",
"--license",
"GPL-3.0-or-later",
"--copyright",
"Jane Doe",
copyright_prefix,
"string",
"foo.py",
],
out=stringio,
)

assert result == 0
assert simple_file.read_text() == expected


def test_annotate_shebang(fake_repository, stringio):
"""Keep the shebang when annotating."""
simple_file = fake_repository / "foo.py"
Expand Down

0 comments on commit dbfabbd

Please sign in to comment.