-
Notifications
You must be signed in to change notification settings - Fork 29
Python 3.13 support. Monkey patches doctest in conftest.py, so doctests pass against both numpy 1 and numpy 2 #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JamesParrott
wants to merge
10
commits into
vnmabus:develop
Choose a base branch
from
JamesParrott:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
05924cc
Don't omit dcor/tests from pytest
JamesParrott 528567e
Revert "Don't omit dcor/tests from pytest"
JamesParrott 929b90e
Relax numpy < 2 pin in testing deps
JamesParrott d1b771b
Try to skip doctests
JamesParrott d6de854
Update conftest.py
JamesParrott 3681832
Update conftest.py
JamesParrott 2b122d3
Test on 3.13 too
JamesParrott c5c0b89
Disable type checking on conftest.py (it dynamically patches the core…
JamesParrott 021fc4d
Update main.yml
JamesParrott a73e8a2
Convert docstring repr expected and actual to numpy 1 style repr
JamesParrott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
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.