From 84544d811c2c2ff65a39d261a5eed0fac3120278 Mon Sep 17 00:00:00 2001 From: faymanns Date: Fri, 24 Jan 2025 16:06:33 +0100 Subject: [PATCH] Add doctesting to CI --- .github/workflows/test_and_deploy.yml | 2 +- pyproject.toml | 3 --- src/conftest.py | 24 ++++++++++++++++++++++++ tox.ini | 6 ++++-- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/conftest.py diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 9e9d794..e5c5be9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: platform: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 1fd5082..ade5d41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,9 +31,6 @@ ignore = [ "A003", # shadowing of a Python builtin ] -[tool.pytest.ini_options] -addopts = "--doctest-modules" - exclude = [ ".bzr", ".direnv", diff --git a/src/conftest.py b/src/conftest.py new file mode 100644 index 0000000..cd09867 --- /dev/null +++ b/src/conftest.py @@ -0,0 +1,24 @@ +""" +Fixtures for doctesting +""" +import matplotlib.pyplot as plt +import numpy as np +import pytest +import splinebox + + +@pytest.fixture(autouse=True) +def add_np(doctest_namespace): + doctest_namespace["np"] = np + if np.__version__ >= "2.0.0": + np.set_printoptions(legacy="1.25") + + +@pytest.fixture(autouse=True) +def add_splinebox(doctest_namespace): + doctest_namespace["splinebox"] = splinebox + + +@pytest.fixture(autouse=True) +def add_plt(doctest_namespace): + doctest_namespace["plt"] = plt diff --git a/tox.ini b/tox.ini index a13f201..76437da 100644 --- a/tox.ini +++ b/tox.ini @@ -25,5 +25,7 @@ passenv = CI GITHUB_ACTIONS extras = - test -commands = pytest -v --color=yes --cov=splinebox --cov-report=xml + test,examples +commands = + pytest -v --color=yes --doctest-modules src + pytest -v --color=yes --cov=splinebox --cov-report=xml