Skip to content

Commit 11982d8

Browse files
committed
Update other version numbers in README.rst
1 parent d8077ea commit 11982d8

File tree

2 files changed

+62
-9
lines changed

2 files changed

+62
-9
lines changed

release.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,39 @@ def tweak_readme(tag: Tag, filename: str = "README.rst") -> None:
448448

449449
# Update first line: "This is Python version 3.14.0 alpha 7"
450450
# and update length of underline in second line to match.
451-
lines = readme.read_text().splitlines()
451+
content = readme.read_text()
452+
lines = content.splitlines()
452453
this_is = f"This is Python version {tag.long_name}"
453454
underline = "=" * len(this_is)
454455
lines[0] = this_is
455456
lines[1] = underline
457+
content = "\n".join(lines)
456458

457-
readme.write_text("\n".join(lines))
459+
DOCS_URL = r"https://docs\.python\.org/"
460+
X_Y = r"\d+\.\d+"
461+
462+
# Replace in: 3.14 <https://docs.python.org/3.14/whatsnew/3.14.html>`_
463+
content = re.sub(
464+
rf"{X_Y} (<{DOCS_URL}){X_Y}(/whatsnew/){X_Y}(\.html>`_)",
465+
rf"{tag.basic_version} \g<1>{tag.basic_version}\g<2>{tag.basic_version}\g<3>",
466+
content,
467+
)
468+
469+
# Replace in: `Documentation for Python 3.14 <https://docs.python.org/3.14/>`_
470+
content = re.sub(
471+
rf"(`Documentation for Python ){X_Y}( <{DOCS_URL}){X_Y}(/>`_)",
472+
rf"\g<1>{tag.basic_version}\g<2>{tag.basic_version}\g<3>",
473+
content,
474+
)
475+
476+
# Replace in "for Python 3.14 release details"
477+
content = re.sub(
478+
rf"(for Python ){X_Y}( release details)",
479+
rf"\g<1>{tag.basic_version}\g<2>",
480+
content,
481+
)
482+
483+
readme.write_text(content)
458484
print("done")
459485

460486

tests/test_release.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,57 @@ def test_tweak_patchlevel(tmp_path: Path) -> None:
7171

7272

7373
@pytest.mark.parametrize(
74-
["test_tag", "expected_version", "expected_underline"],
74+
[
75+
"test_tag",
76+
"expected_version",
77+
"expected_underline",
78+
"expected_whatsnew",
79+
"expected_docs",
80+
"expected_release_details_text",
81+
],
7582
[
7683
(
7784
"3.14.0a6",
7885
"This is Python version 3.14.0 alpha 6",
7986
"=====================================",
87+
"3.14 <https://docs.python.org/3.14/whatsnew/3.14.html>`_",
88+
"`Documentation for Python 3.14 <https://docs.python.org/3.14/>`_",
89+
"for Python 3.14 release details",
8090
),
8191
(
8292
"3.14.0b2",
8393
"This is Python version 3.14.0 beta 2",
8494
"====================================",
95+
"3.14 <https://docs.python.org/3.14/whatsnew/3.14.html>`_",
96+
"`Documentation for Python 3.14 <https://docs.python.org/3.14/>`_",
97+
"for Python 3.14 release details",
8598
),
8699
(
87100
"3.14.0rc2",
88101
"This is Python version 3.14.0 release candidate 2",
89102
"=================================================",
103+
"3.14 <https://docs.python.org/3.14/whatsnew/3.14.html>`_",
104+
"`Documentation for Python 3.14 <https://docs.python.org/3.14/>`_",
105+
"for Python 3.14 release details",
90106
),
91107
(
92-
"3.14.1",
93-
"This is Python version 3.14.1",
108+
"3.15.1",
109+
"This is Python version 3.15.1",
94110
"=============================",
111+
"3.15 <https://docs.python.org/3.15/whatsnew/3.15.html>`_",
112+
"`Documentation for Python 3.15 <https://docs.python.org/3.15/>`_",
113+
"for Python 3.15 release details",
95114
),
96115
],
97116
)
98117
def test_tweak_readme(
99-
tmp_path: Path, test_tag: str, expected_version: str, expected_underline: str
118+
tmp_path: Path,
119+
test_tag: str,
120+
expected_version: str,
121+
expected_underline: str,
122+
expected_whatsnew: str,
123+
expected_docs: str,
124+
expected_release_details_text: str,
100125
) -> None:
101126
# Arrange
102127
tag = release.Tag(test_tag)
@@ -110,8 +135,10 @@ def test_tweak_readme(
110135
release.tweak_readme(tag, filename=str(readme_file))
111136

112137
# Assert
113-
original_lines = original_contents.splitlines()
114-
new_lines = readme_file.read_text().splitlines()
138+
new_contents = readme_file.read_text()
139+
new_lines = new_contents.splitlines()
115140
assert new_lines[0] == expected_version
116141
assert new_lines[1] == expected_underline
117-
assert new_lines[2:] == original_lines[2:]
142+
assert expected_whatsnew in new_contents
143+
assert expected_docs in new_contents
144+
assert expected_release_details_text in new_contents

0 commit comments

Comments
 (0)