Skip to content

Commit

Permalink
config pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Oct 30, 2024
1 parent 3917e36 commit b696583
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pathlib

from _pytest.nodes import Collector
from _pytest.doctest import DoctestModule

collect_ignore = ["src/scripts/cysignals-CSI-helper.py"]

"""Collect doctests in cython files and run them as test modules."""
def pytest_collect_file(
file_path: pathlib.Path,
parent: Collector,
) -> DoctestModule | None:
config = parent.config
if file_path.suffix == ".pyx":
if config.option.doctestmodules:
return DoctestModule.from_parent(parent, path=file_path)
return None
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ classifiers = [
]
urls = { Homepage = "https://github.com/sagemath/cysignals" }
requires-python = ">=3.9"

[tool.pytest.ini_options]
addopts = "--doctest-modules"
norecursedirs = "builddir docs"

0 comments on commit b696583

Please sign in to comment.