Skip to content

Commit b696583

Browse files
committed
config pytest
1 parent 3917e36 commit b696583

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pathlib
2+
3+
from _pytest.nodes import Collector
4+
from _pytest.doctest import DoctestModule
5+
6+
collect_ignore = ["src/scripts/cysignals-CSI-helper.py"]
7+
8+
"""Collect doctests in cython files and run them as test modules."""
9+
def pytest_collect_file(
10+
file_path: pathlib.Path,
11+
parent: Collector,
12+
) -> DoctestModule | None:
13+
config = parent.config
14+
if file_path.suffix == ".pyx":
15+
if config.option.doctestmodules:
16+
return DoctestModule.from_parent(parent, path=file_path)
17+
return None

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ classifiers = [
3131
]
3232
urls = { Homepage = "https://github.com/sagemath/cysignals" }
3333
requires-python = ">=3.9"
34+
35+
[tool.pytest.ini_options]
36+
addopts = "--doctest-modules"
37+
norecursedirs = "builddir docs"

0 commit comments

Comments
 (0)