Skip to content
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Run tests
run: |
pip3 install ".[test]"
coverage run --source=dcor/ --omit=dcor/tests/ -m pytest
coverage run --source=dcor/ --omit=dcor/tests/ -m pytest --doctest-glob=""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, that's from a previous experiment. I'll remove it.


- name: Generate coverage XML
run: |
Expand Down
31 changes: 31 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
# type: ignore
import re
import doctest

collect_ignore = ['setup.py']

pytest_plugins = ("pytest_cov", "subtests")


OutputChecker = doctest.OutputChecker



class Numpy1Numpy2AgnosticOutputChecker(doctest.OutputChecker):

numpy2_float64_pattern = r'np\.float64\((?P<num>inf|[+-]?\d*\.\d+)\)'

def check_output(self, want, got, optionflags):

numpy_1_style_got = re.sub(
self.numpy2_float64_pattern,
lambda m: m['num'],
got,
)

return super().check_output(want, numpy_1_style_got, optionflags)




def pytest_configure(config):
import sys
sys._called_from_test = True
doctest.OutputChecker = Numpy1Numpy2AgnosticOutputChecker



def pytest_unconfigure(config):
import sys
del sys._called_from_test
doctest.OutputChecker = OutputChecker



4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ docs = [
]
test = [
"array-api-strict",
"numpy<2", # NumPy 2 changes array repr, affecting doctests.
"numpy",
"pytest",
"pytest-cov",
"pytest-subtests",
Expand All @@ -78,4 +78,4 @@ build-backend = "setuptools.build_meta"
include = ["dcor*"]

[tool.setuptools.dynamic]
version = {attr = "dcor.__version__"}
version = {attr = "dcor.__version__"}