Skip to content

Commit 6bc1e72

Browse files
committed
Add tests to increase coverage
1 parent 1e6029f commit 6bc1e72

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pep_sphinx_extensions/tests/pep_lint/test_pep_lint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
from ..conftest import PEP_ROOT
6+
57
PEP_9002 = Path(__file__).parent.parent / "peps" / "pep-9002.rst"
68

79

@@ -46,3 +48,10 @@ def test_with_fake_pep():
4648
(20, "Resolution must be a valid thread URL"),
4749
(23, "Use the :pep:`NNN` role to refer to PEPs"),
4850
]
51+
52+
53+
def test_skip_direct_pep_link_check():
54+
filename = PEP_ROOT / "pep-0009.rst" # in SKIP_DIRECT_PEP_LINK_CHECK
55+
content = filename.read_text(encoding="utf-8").splitlines()
56+
warnings = list(check_peps.check_peps(filename, content))
57+
assert warnings == []

pep_sphinx_extensions/tests/pep_lint/test_post_url.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ def test_validate_post_history_valid(body: str):
7979
assert warnings == [], warnings
8080

8181

82+
@pytest.mark.parametrize(
83+
"body",
84+
[
85+
"31-Jul-2015 <https://discuss.python.org/t/123456>`__,",
86+
"`31-Jul-2015 <https://discuss.python.org/t/123456>",
87+
],
88+
)
89+
def test_validate_post_history_unbalanced_link(body: str):
90+
warnings = [warning for (_, warning) in check_peps._validate_post_history(1, body)]
91+
assert warnings == [
92+
"post line must be a date or both start with “`” and end with “>`__”"
93+
], warnings
94+
95+
8296
@pytest.mark.parametrize(
8397
"line",
8498
[
@@ -118,6 +132,20 @@ def test_validate_resolution_invalid(line: str):
118132
assert warnings == ["Resolution must be a valid thread URL"], warnings
119133

120134

135+
@pytest.mark.parametrize(
136+
"line",
137+
[
138+
"01-Jan-2000 <https://mail.python.org/pipermail/list-name/0000-Month/0123456.html>`__",
139+
"`01-Jan-2000 <https://mail.python.org/pipermail/list-name/0000-Month/0123456.html>",
140+
],
141+
)
142+
def test_validate_resolution_unbalanced_link(line: str):
143+
warnings = [warning for (_, warning) in check_peps._validate_resolution(1, line)]
144+
assert warnings == [
145+
"Resolution line must be a link or both start with “`” and end with “>`__”"
146+
], warnings
147+
148+
121149
@pytest.mark.parametrize(
122150
"thread_url",
123151
[

0 commit comments

Comments
 (0)