Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .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 Down
35 changes: 35 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
# type: ignore
import re
import doctest

collect_ignore = ['setup.py']

pytest_plugins = ("pytest_cov", "subtests")


OutputChecker = doctest.OutputChecker


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

def ensure_numpy_1_style_repr(repr_: str)-> str:
return re.sub(
numpy2_float64_pattern,
lambda m: m['num'],
repr_,
)


class Numpy1Numpy2AgnosticOutputChecker(doctest.OutputChecker):

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

numpy_1_style_want = ensure_numpy_1_style_repr(want)
numpy_1_style_got = ensure_numpy_1_style_repr(got)

return super().check_output(numpy_1_style_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__"}
Loading