-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
This issue discusses the feature request presented in PR #7695.
Currently conditions in skip and xfail markers can have two forms:
- A boolean (=> a regular Python expression evaluated normally during collection). Can only access global Python values.
- A string of a Python expression. Evaluated during setup/call time. Has access to
os
,sys
,platform
,config
.
The feature request is to be able to skip based on custom user values. Proposed solutions so far are:
-
Use the boolean with global variables. This is not so nice because can't the lifecycle can't be controlled, and importing the necessary values add boilerplate.
-
(PR Allow contibuting additional global variables for skipif/xfail #7695 by @s0undt3ch) Add a new hook
pytest_markeval_namespace
which can add new values to theos
,sys
... list above. Works only for string conditions. -
Add a new condition type, a callable, which is evaluated lazily. Allow this callable to take fixtures, as if requested by the item.
We agreed to try approach 3 (or another proposal) for pytest 6.2, but if we don't get to it, merge approach 2.