Skip to content

Commit

Permalink
test: add a test for pr #101
Browse files Browse the repository at this point in the history
  • Loading branch information
Ned Batchelder committed Jul 18, 2023
1 parent d959940 commit fc2ee98
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions changelog.d/20230718_185443_nedbat_add_101_test.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Fixed
.....

- Changelogs with non-version headings now produce an understandable error
message from ``scriv collect``, thanks to `James Gerity <pull 101_>`_, fixing
`issue 100`_.

.. _issue 100: https://github.com/nedbat/scriv/pull/100
.. _pull 101: https://github.com/nedbat/scriv/pull/101
33 changes: 33 additions & 0 deletions tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,36 @@ def test_duplicate_version_with_v(cli_invoke, changelog_d, temp_dir):
str(result.exception)
== "Entry 'v12.34.56 — 2022-09-18' already uses version '12.34.56'."
)


def test_unparsable_version(cli_invoke, changelog_d, temp_dir):
(changelog_d / "scriv.ini").write_text("[scriv]\nversion = 12.34.56\n")
(temp_dir / "CHANGELOG.rst").write_text(
textwrap.dedent(
"""\
Preamble that doesn't count
v12.34.57 — 2022-09-19
======================
A quick fix.
Not a version at all.
=====================
Good stuff.
"""
),
encoding="utf-8",
)

# Make a new fragment, and collect again without changing the version.
(changelog_d / "20170617_nedbat.rst").write_text(FRAG2)
with freezegun.freeze_time("2022-09-18T16:18:19"):
result = cli_invoke(["collect"], expect_ok=False)
assert result.exit_code == 1
assert str(result.exception) == (
"Entry 'Not a version at all.' is not a valid version! "
+ "If scriv should ignore this heading, add "
+ "'scriv-end-here' somewhere before it."
)

0 comments on commit fc2ee98

Please sign in to comment.