Skip to content

Commit

Permalink
Add tests to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Oct 16, 2024
1 parent 1e6029f commit 1aca0a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pep_sphinx_extensions/tests/pep_lint/test_pep_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import check_peps # NoQA: inserted into sys.modules in conftest.py

from ..conftest import PEP_ROOT

PEP_9002 = Path(__file__).parent.parent / "peps" / "pep-9002.rst"


Expand Down Expand Up @@ -46,3 +48,10 @@ def test_with_fake_pep():
(20, "Resolution must be a valid thread URL"),
(23, "Use the :pep:`NNN` role to refer to PEPs"),
]


def test_skip_direct_pep_link_check():
filename = PEP_ROOT / "pep-0009.rst" # in SKIP_DIRECT_PEP_LINK_CHECK
content = filename.read_text(encoding="utf-8").splitlines()
warnings = list(check_peps.check_peps(filename, content))
assert warnings == []
28 changes: 28 additions & 0 deletions pep_sphinx_extensions/tests/pep_lint/test_post_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ def test_validate_post_history_valid(body: str):
assert warnings == [], warnings


@pytest.mark.parametrize(
"body",
[
"31-Jul-2015 <https://discuss.python.org/t/123456>`__,",
"`31-Jul-2015 <https://discuss.python.org/t/123456>",
],
)
def test_validate_post_history_unbalanced_link(body: str):
warnings = [warning for (_, warning) in check_peps._validate_post_history(1, body)]
assert warnings == [
"post line must be a date or both start with “`” and end with “>`__”"
], warnings


@pytest.mark.parametrize(
"line",
[
Expand Down Expand Up @@ -118,6 +132,20 @@ def test_validate_resolution_invalid(line: str):
assert warnings == ["Resolution must be a valid thread URL"], warnings


@pytest.mark.parametrize(
"line",
[
"01-Jan-2000 <https://mail.python.org/pipermail/list-name/0000-Month/0123456.html>`__",
"`01-Jan-2000 <https://mail.python.org/pipermail/list-name/0000-Month/0123456.html>",
],
)
def test_validate_resolution_unbalanced_link(line: str):
warnings = [warning for (_, warning) in check_peps._validate_resolution(1, line)]
assert warnings == [
"Resolution line must be a link or both start with “`” and end with “>`__”"
], warnings


@pytest.mark.parametrize(
"thread_url",
[
Expand Down

0 comments on commit 1aca0a0

Please sign in to comment.