Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ optional-dependencies.tests = [
"pyfakefs",
"pytest",
"pytest-cov",
"time-machine",
]
urls.Changelog = "https://github.com/python/blurb/blob/main/CHANGELOG.md"
urls.Homepage = "https://github.com/python/blurb"
Expand Down
6 changes: 6 additions & 0 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ def printable_version(version):
return version + " final"


def format_blurb_filename(section, gh_issue, body, date=None):
if date is None:
date = sortable_datetime()
return f"Misc/NEWS.d/{section}/{date}.gh-issue-{gh_issue}.{nonceify(body)}.rst"


class BlurbError(RuntimeError):
pass

Expand Down
28 changes: 28 additions & 0 deletions tests/test_blurb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import time_machine

from blurb import blurb

Expand Down Expand Up @@ -176,6 +177,33 @@ def test_printable_version(version, expected):
assert blurb.printable_version(version) == expected


@time_machine.travel("2025-01-07 16:28:41")
@pytest.mark.parametrize(
"date, expected",
(
(
"2025-02-27-01-12-11",
"Misc/NEWS.d/Library/2025-02-27-01-12-11.gh-issue-123456.hvsmnR.rst",
),
(
None,
"Misc/NEWS.d/Library/2025-01-07-16-28-41.gh-issue-123456.hvsmnR.rst",
),
),
)
def test_format_blurb_filename(date, expected):
# Arrange
gh_issue = "123456"
section = "Library"
body = "Hello world!"

# Act
filename = blurb.format_blurb_filename(section, gh_issue, body, date)

# Assert
assert filename == expected


@pytest.mark.parametrize(
"news_entry, expected_section",
(
Expand Down
Loading