Repository navigation
Validate gh-issue is int before checking range, and that gh-issue or bpo exists #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4cb4857
8e590fc
657a617
04b6913
ac5a101
60f10af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import pytest | ||
| from pyfakefs.fake_filesystem import FakeFilesystem | ||
|
|
||
| from blurb import blurb | ||
|
|
||
|
|
@@ -188,3 +187,68 @@ def test_version(capfd): | |
| # Assert | ||
| captured = capfd.readouterr() | ||
| assert captured.out.startswith("blurb version ") | ||
|
|
||
|
|
||
| def test_parse(): | ||
| # Arrange | ||
| contents = ".. gh-issue: 123456\n.. section: IDLE\nHello world!" | ||
| blurbs = blurb.Blurbs() | ||
|
|
||
| # Act | ||
| blurbs.parse(contents) | ||
|
|
||
| # Assert | ||
| metadata, body = blurbs[0] | ||
| assert metadata["gh-issue"] == "123456" | ||
| assert metadata["section"] == "IDLE" | ||
| assert body == "Hello world!\n" | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "contents, expected_error", | ||
| ( | ||
| ( | ||
| "", | ||
| r"Blurb 'body' text must not be empty!", | ||
| ), | ||
| ( | ||
| "gh-issue: Hello world!", | ||
| r"Blurb 'body' can't start with 'gh-'!", | ||
| ), | ||
| ( | ||
| ".. gh-issue: 1\n.. section: IDLE\nHello world!", | ||
| r"The gh-issue number must be 32426 or above, not a PR number", | ||
| ), | ||
| ( | ||
| ".. bpo: one-two\n.. section: IDLE\nHello world!", | ||
| r"Invalid bpo issue number! \('one-two'\)", | ||
| ), | ||
| ( | ||
| ".. gh-issue: one-two\n.. section: IDLE\nHello world!", | ||
| r"Invalid GitHub issue number! \('one-two'\)", | ||
|
hugovk marked this conversation as resolved.
Resolved
|
||
| ), | ||
| ( | ||
| ".. gh-issue: 123456\n.. section: Funky Kong\nHello world!", | ||
| r"Invalid section 'Funky Kong'! You must use one of the predefined sections", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you trying to get us sued by Nintendo?!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funky Kong already lives here :D https://github.com/python/blurb/blob/main/tests/fail/invalid-section.rst?plain=1 |
||
| ), | ||
| ( | ||
| ".. gh-issue: 123456\nHello world!", | ||
| r"No 'section' specified. You must provide one!", | ||
| ), | ||
| ( | ||
| ".. gh-issue: 123456\n.. section: IDLE\n.. section: IDLE\nHello world!", | ||
| r"Blurb metadata sets 'section' twice!", | ||
| ), | ||
| ( | ||
| ".. section: IDLE\nHello world!", | ||
| r"'gh-issue:' or 'bpo:' must be specified in the metadata!", | ||
| ), | ||
| ), | ||
| ) | ||
| def test_parse_no_body(contents, expected_error): | ||
| # Arrange | ||
| blurbs = blurb.Blurbs() | ||
|
|
||
| # Act / Assert | ||
| with pytest.raises(blurb.BlurbError, match=expected_error): | ||
| blurbs.parse(contents) | ||
Uh oh!
There was an error while loading. Please reload this page.