Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into no-spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jan 17, 2024
2 parents 22b23c9 + a51e311 commit 3e0a0ba
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 45 deletions.
5 changes: 1 addition & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma:
pragma: no cover

exclude_also =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
def main
Expand Down
5 changes: 5 additions & 0 deletions blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ def finish_entry():

no_changes = metadata.get('no changes')

lowest_possible_gh_issue_number = 32426

issue_keys = {
'gh-issue': 'GitHub',
'bpo': 'bpo',
Expand All @@ -474,6 +476,9 @@ def finish_entry():
# we'll complain about the *first* error
# we see in the blurb file, which is a
# better user experience.
if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number:
throw(f"The gh-issue number must be {lowest_possible_gh_issue_number} or above, not a PR number.")

if key in issue_keys:
try:
int(value)
Expand Down
4 changes: 4 additions & 0 deletions blurb/tests/fail/small-gh-number.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. gh-issue: 100
.. section: Library
This is an invalid blurb. GitHub issues should be 32426 or above.
2 changes: 1 addition & 1 deletion blurb/tests/pass/basic.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 2017-05-02
.. gh-issue: 0
.. gh-issue: 40000
.. nonce: xyz
.. section: Library
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/basic.rst.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 2017-05-02
.. gh-issue: 0
.. gh-issue: 40000
.. nonce: xyz
.. section: Library

Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/case-insensitive.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 2017-05-02
.. GH-Issue: 0
.. GH-Issue: 35000
.. nonce: xyz
.. section: Library
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/case-insensitive.rst.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 2017-05-02
.. gh-issue: 0
.. gh-issue: 35000
.. nonce: xyz
.. section: Library

Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/no-break-long-words.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 1234
.. gh-issue: 0
.. gh-issue: 35000
.. nonce: xyz
.. section: Library
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/no-break-long-words.rst.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 1234
.. gh-issue: 0
.. gh-issue: 35000
.. nonce: xyz
.. section: Library

Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/no-break-on-hyphens.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 7333
.. gh-issue: 21121
.. gh-issue: 41121
.. nonce: ZLsRil
.. section: Library
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/no-break-on-hyphens.rst.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. date: 7333
.. gh-issue: 21121
.. gh-issue: 41121
.. nonce: ZLsRil
.. section: Library

Expand Down
64 changes: 31 additions & 33 deletions blurb/tests/test_blurb.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
import pytest
from pyfakefs.fake_filesystem import FakeFilesystem

import blurb


UNCHANGED_SECTIONS = (
"Library",
)


@pytest.mark.parametrize("section", UNCHANGED_SECTIONS)
def test_sanitize_section_no_change(section):
sanitized = blurb.sanitize_section(section)
assert sanitized == section


@pytest.mark.parametrize(
"section, expected",
(
("C API", "C_API"),
("Core and Builtins", "Core_and_Builtins"),
("Library", "Library"),
("Tools/Demos", "Tools-Demos"),
),
)
def test_sanitize_section(section, expected):
def test_sanitize_section_changed(section, expected):
sanitized = blurb.sanitize_section(section)
assert sanitized == expected


@pytest.mark.parametrize(
"section, expected",
(
("C API", "C API"),
("Core and Builtins", "Core and Builtins"),
("Library", "Library"),
("Tools/Demos", "Tools-Demos"),
),
)
def test_sanitize_section_legacy(section, expected):
sanitized = blurb.sanitize_section_legacy(section)
assert sanitized == expected
@pytest.mark.parametrize("section", UNCHANGED_SECTIONS)
def test_unsanitize_section_no_change(section):
unsanitized = blurb.unsanitize_section(section)
assert unsanitized == section


@pytest.mark.parametrize(
"section, expected",
(
("C_API", "C API"),
("C API", "C API"),
("Core_and_Builtins", "Core and Builtins"),
("Core and Builtins", "Core and Builtins"),
("Library", "Library"),
("Tools-Demos", "Tools/Demos"),
),
)
def test_unsanitize_section(section, expected):
def test_unsanitize_section_changed(section, expected):
unsanitized = blurb.unsanitize_section(section)
assert unsanitized == expected

Expand Down Expand Up @@ -110,27 +108,27 @@ def test_glob_blurbs_sort_order(fs):
"news_entry, expected_section",
(
(
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-11111.pC7gnM.rst",
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-33333.pC7gnM.rst",
"Library",
),
(
"Misc/NEWS.d/next/Core_and_Builtins/2023-03-17-12-09-45.gh-issue-22222.Pf_BI7.rst",
"Misc/NEWS.d/next/Core_and_Builtins/2023-03-17-12-09-45.gh-issue-44444.Pf_BI7.rst",
"Core and Builtins",
),
(
"Misc/NEWS.d/next/Core and Builtins/2023-03-17-12-09-45.gh-issue-33333.Pf_BI7.rst",
"Misc/NEWS.d/next/Core and Builtins/2023-03-17-12-09-45.gh-issue-55555.Pf_BI7.rst",
"Core and Builtins",
),
(
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-44444.2F1Byz.rst",
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-66666.2F1Byz.rst",
"Tools/Demos",
),
(
"Misc/NEWS.d/next/C_API/2023-03-27-22-09-07.gh-issue-55555.3SN8Bs.rst",
"Misc/NEWS.d/next/C_API/2023-03-27-22-09-07.gh-issue-77777.3SN8Bs.rst",
"C API",
),
(
"Misc/NEWS.d/next/C API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
"Misc/NEWS.d/next/C API/2023-03-27-22-09-07.gh-issue-88888.3SN8Bs.rst",
"C API",
),
),
Expand All @@ -152,19 +150,19 @@ def test_load_next(news_entry, expected_section, fs):
"news_entry, expected_path",
(
(
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-11111.pC7gnM.rst",
"root/Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-11111.pC7gnM.rst",
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-33333.pC7gnM.rst",
"root/Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-33333.pC7gnM.rst",
),
(
"Misc/NEWS.d/next/Core_and_Builtins/2023-03-17-12-09-45.gh-issue-33333.Pf_BI7.rst",
"root/Misc/NEWS.d/next/Core_and_Builtins/2023-03-17-12-09-45.gh-issue-33333.Pf_BI7.rst",
"Misc/NEWS.d/next/Core and Builtins/2023-03-17-12-09-45.gh-issue-44444.Pf_BI7.rst",
"root/Misc/NEWS.d/next/Core_and_Builtins/2023-03-17-12-09-45.gh-issue-44444.Pf_BI7.rst",
),
(
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-44444.2F1Byz.rst",
"root/Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-44444.2F1Byz.rst",
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-55555.2F1Byz.rst",
"root/Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-55555.2F1Byz.rst",
),
(
"Misc/NEWS.d/next/C_API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
"Misc/NEWS.d/next/C API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
"root/Misc/NEWS.d/next/C_API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
),
),
Expand Down

0 comments on commit 3e0a0ba

Please sign in to comment.