Skip to content

Commit 7d0acfb

Browse files
njzjzCopilotpre-commit-ci[bot]
authored
chore(test): skip ChemRxiv tests (#85)
Commented out a ReferenceCase for a ChemRxiv paper. ChemRxiv API is broken again. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent da93e32 commit 7d0acfb

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

tests/cases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ReferenceCase:
1717
expected_markdown: str
1818
pmid: int | None = None
1919
arxiv: str | None = None
20+
skip_reason: str | None = None
2021

2122
@property
2223
def expected_text(self) -> str:
@@ -465,6 +466,7 @@ def expected_text(self) -> str:
465466
applications in drug development and beyond.},
466467
}""").strip(),
467468
expected_markdown=r"Manyi Yang, Duo Zhang, Xinyan Wang, Lingfeng Zhang, Tong Zhu, Han Wang, Ab initio Accuracy Neural Network Potential for Drug-like Molecules, *ChemRxiv*, 2024, DOI: [10.26434/chemrxiv-2024-sq8nh](https://doi.org/10.26434/chemrxiv-2024-sq8nh). [![Citations](https://citations.njzjz.win/10.26434/chemrxiv-2024-sq8nh)](https://badge.dimensions.ai/details/doi/10.26434/chemrxiv-2024-sq8nh)",
469+
skip_reason="ChemRxiv API broken",
468470
),
469471
# chapter
470472
ReferenceCase(

tests/test_from_identifier.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,35 @@
66

77
from wenxian.from_identifier import from_identifier
88

9-
from .cases import TEST_CASES
9+
from .cases import TEST_CASES, ReferenceCase
10+
11+
12+
def _create_test_param(test_case: ReferenceCase, identifier: str | None):
13+
"""Create a pytest.param with skip marks if needed."""
14+
return pytest.param(
15+
identifier,
16+
test_case.reference,
17+
marks=pytest.mark.skip(reason=test_case.skip_reason)
18+
if test_case.skip_reason
19+
else (),
20+
)
1021

1122

1223
@pytest.mark.parametrize(
1324
"identifier, expected",
1425
[
15-
*[(test_case.reference.doi, test_case.reference) for test_case in TEST_CASES],
26+
*[
27+
_create_test_param(test_case, test_case.reference.doi)
28+
for test_case in TEST_CASES
29+
],
1630
*[
1731
# from_identifier accept str
18-
(str(test_case.pmid), test_case.reference)
32+
_create_test_param(test_case, str(test_case.pmid))
1933
for test_case in TEST_CASES
2034
if test_case.pmid is not None
2135
],
2236
*[
23-
(test_case.arxiv, test_case.reference)
37+
_create_test_param(test_case, test_case.arxiv)
2438
for test_case in TEST_CASES
2539
if test_case.arxiv is not None
2640
],

tests/test_output.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,44 @@
66

77
import pytest
88

9-
from .cases import TEST_CASES
9+
from .cases import TEST_CASES, ReferenceCase
1010

1111
if TYPE_CHECKING:
1212
from wenxian.reference import Reference
1313

1414

15+
def _create_test_param(test_case: ReferenceCase, expected_value: str):
16+
"""Create a pytest.param with skip marks if needed."""
17+
return pytest.param(
18+
test_case.reference,
19+
expected_value,
20+
marks=pytest.mark.skip(reason=test_case.skip_reason)
21+
if test_case.skip_reason
22+
else (),
23+
)
24+
25+
1526
@pytest.mark.parametrize(
16-
"reference, expected", [(cc.reference, cc.expected_bibtex) for cc in TEST_CASES]
27+
"reference, expected",
28+
[_create_test_param(cc, cc.expected_bibtex) for cc in TEST_CASES],
1729
)
1830
def test_bibtex(reference: Reference, expected):
1931
"""Test generating BibTeX entries from references."""
2032
assert reference.bibtex.strip() == expected
2133

2234

2335
@pytest.mark.parametrize(
24-
"reference, expected", [(cc.reference, cc.expected_markdown) for cc in TEST_CASES]
36+
"reference, expected",
37+
[_create_test_param(cc, cc.expected_markdown) for cc in TEST_CASES],
2538
)
2639
def test_markdown(reference: Reference, expected):
2740
"""Test generating Markdown from references."""
2841
assert reference.markdown.strip() == expected
2942

3043

3144
@pytest.mark.parametrize(
32-
"reference, expected", [(cc.reference, cc.expected_text) for cc in TEST_CASES]
45+
"reference, expected",
46+
[_create_test_param(cc, cc.expected_text) for cc in TEST_CASES],
3347
)
3448
def test_text(reference: Reference, expected):
3549
"""Test generating text from references."""

0 commit comments

Comments
 (0)