Skip to content

ENH: Add pytest_extra_requires to conditionally ignore paths / skip functions unless requirements are met #204

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

Merged
merged 5 commits into from
Jun 23, 2025

Conversation

ev-br
Copy link
Member

@ev-br ev-br commented Jun 12, 2025

fixes gh-197

dt_config = DTConfig()

dt_config.pytest_extra_requires = {
   "path/to/file" : "cupy>=2.3.4",
  "full.function.name": "cupy"
}

Potential follow-ups

  • spin-made dev builds do not play nice with packaging.requirements.version. Can add a fallback to __version__. This is only relevant if a spin-built package is a dependency, so this should be very rare. Probably not worth bothering until a there's a real use case.
  • allow setting per-doctest requirements: {"module.func": "cupy>2.3.4"}, similar to pytest_extra_ignore

ev-br added 2 commits June 11, 2025 09:52
Use fnmatch_ex from _pytest.pathlib to match pytest itself.
This allows to conditionally skip/ignore paths depending
on the PEP 508 requirements:

pytest_extra_requires = {
   "path/to/file" : "cupy>=2.3.4"
}
@ev-br ev-br added the enhancement New features w.r.t. the original refguide-check label Jun 12, 2025
@ev-br
Copy link
Member Author

ev-br commented Jun 12, 2025

@flying-sheep would you be interested in giving this a spin to see if this addresses your request in gh-197?

Copy link
Contributor

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

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

Looks great, only things can have multiple requirements, so that should be handled.

@ev-br ev-br changed the title Add pytest_extra_requires to conditionally ignore paths unless requirements are met Add pytest_extra_requires to conditionally ignore paths / skip functions unless requirements are met Jun 12, 2025
@ev-br ev-br force-pushed the optional_requirements branch from a9eecd9 to fd5a2db Compare June 12, 2025 11:52
@ev-br
Copy link
Member Author

ev-br commented Jun 12, 2025

multiple requirements,

Thanks! Your edits are in.

Adding dt_config.pytest_extra_requires ={"scipy.linalg.solve" : ["cupy", "numpy>2"]} seems to do just what it says on the tin.
This is a pure enhancement and has no backwards compatibility concerns. I'll keep it open for a short while to see if there are further comments, then merge.

@ev-br ev-br mentioned this pull request Jun 20, 2025
@ev-br
Copy link
Member Author

ev-br commented Jun 23, 2025

No further comments, so let's land this and iterate as necessary. Thanks a whole lot @flying-sheep !

@ev-br ev-br merged commit 01e8250 into main Jun 23, 2025
14 checks passed
@ev-br ev-br added this to the v2.0 milestone Jun 23, 2025
@ev-br ev-br changed the title Add pytest_extra_requires to conditionally ignore paths / skip functions unless requirements are met ENH: Add pytest_extra_requires to conditionally ignore paths / skip functions unless requirements are met Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features w.r.t. the original refguide-check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DoctestPlus and optional dependencies
2 participants