Skip to content

Commit 0f51e78

Browse files
committed
Update doctests
1 parent 55ffb73 commit 0f51e78

6 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
fi
101101
- name: Install dependencies
102102
run: |
103-
pip install pytest-cov
103+
pip install pytest-cov sybil
104104
pip install .
105105
- name: Ensure Python and source code are on same drive (Windows)
106106
if: ${{ matrix.os == 'windows-latest' }}
@@ -111,12 +111,12 @@ jobs:
111111
- name: Test with pytest (Ubuntu & macOS)
112112
if: ${{ matrix.os != 'windows-latest' }}
113113
run: |
114-
pytest --cov=lineage tests
114+
pytest --cov=lineage tests README.md
115115
- name: Test with pytest (Windows)
116116
if: ${{ matrix.os == 'windows-latest' }}
117117
working-directory: C:\a\lineage\lineage
118118
run: |
119-
pytest --cov=lineage tests
119+
pytest --cov=lineage tests README.md
120120
- name: Upload coverage to Codecov (Ubuntu & macOS)
121121
if: ${{ matrix.os != 'windows-latest' }}
122122
uses: codecov/codecov-action@v5

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "Run All Tests",
66
"type": "shell",
7-
"command": "source .venv/bin/activate && python -m pytest tests README.rst",
7+
"command": "source .venv/bin/activate && python -m pytest tests README.md",
88
"group": {
99
"kind": "test",
1010
"isDefault": true
@@ -18,7 +18,7 @@
1818
{
1919
"label": "Test README Examples",
2020
"type": "shell",
21-
"command": "source .venv/bin/activate && python -m doctest README.rst -v",
21+
"command": "source .venv/bin/activate && python -m pytest README.md -v",
2222
"group": "test",
2323
"presentation": {
2424
"reveal": "always",

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To set up `lineage` for local development:
5656
5. When you're done making changes, run all the tests with:
5757

5858
```
59-
$ pipenv run pytest --cov-report=html --cov=lineage tests
59+
$ pipenv run pytest --cov-report=html --cov=lineage tests README.md
6060
```
6161

6262
:::{note}

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pytest-cov = "*"
99
sphinx = "*"
1010
sphinx-rtd-theme = "*"
1111
ruff = "*"
12+
sybil = "*"
1213

1314
[packages]
1415
lineage = {editable = true,path = "."}

conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Pytest configuration for testing code examples in README.md using Sybil.
3+
4+
This conftest.py enables Sybil to parse and test Python code blocks in the
5+
README.md file as part of the pytest test suite. The PythonCodeBlockParser
6+
evaluates fenced Python code blocks (```python), while SkipParser allows
7+
selective skipping of examples using Markdown comments when needed.
8+
"""
9+
10+
from sybil import Sybil
11+
from sybil.parsers.markdown import PythonCodeBlockParser, SkipParser
12+
13+
pytest_collect_file = Sybil(
14+
parsers=[
15+
PythonCodeBlockParser(),
16+
SkipParser(),
17+
],
18+
patterns=["README.md"],
19+
).pytest()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ addopts =
1919
-ra
2020
--strict
2121
--tb=short
22-
--doctest-glob=README.md
22+
-p no:doctest
2323

2424
# http://coverage.readthedocs.io/en/latest/
2525
[coverage:run]

0 commit comments

Comments
 (0)