File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ class DTConfig:
94
94
a string. If not empty, the string value is used as the skip reason.
95
95
pytest_extra_requires : dict
96
96
Paths or functions to conditionally ignore unless requirements are met.
97
- The format is ``{path/or/glob/pattern: requirement, full.func.name: requiremet }``,
97
+ The format is ``{path/or/glob/pattern: requirement(s) , full.func.name: requirement(s) }``,
98
98
where the values are PEP 508 dependency specifiers. If a requirement is not met,
99
99
the behavior is equivalent to using the ``--ignore=...`` command line switch for
100
100
paths, and to using a `pytest_extra_skip` for function names.
Original file line number Diff line number Diff line change @@ -88,9 +88,9 @@ def pytest_ignore_collect(collection_path, config):
88
88
if fnmatch_ex (entry , collection_path ):
89
89
return True
90
90
91
- for entry , req_str in config .dt_config .pytest_extra_requires .items ():
91
+ for entry , reqs in config .dt_config .pytest_extra_requires .items ():
92
92
if fnmatch_ex (entry , collection_path ):
93
- return not is_req_satisfied (req_str )
93
+ return not is_req_satisfied (reqs )
94
94
95
95
96
96
def is_private (item ):
Original file line number Diff line number Diff line change 10
10
import inspect
11
11
from contextlib import contextmanager
12
12
13
+ from typing import Sequence
14
+
13
15
from importlib .metadata import version as get_version , PackageNotFoundError
14
16
from packaging .requirements import Requirement
15
17
@@ -257,12 +259,16 @@ def get_public_objects(module, skiplist=None):
257
259
return (items , names ), failures
258
260
259
261
260
- def is_req_satisfied (req_str ) :
261
- """ Check if a PEP 508-compliant requirement is satisfied or not.
262
+ def is_req_satisfied (req_strs : str | Sequence [ str ]) -> bool :
263
+ """ Check if all PEP 508-compliant requirement(s) are satisfied or not.
262
264
"""
263
- req = Requirement (req_str )
265
+ req_strs = [req_strs ] if isinstance (req_strs , str ) else req_strs
266
+ reqs = [Requirement (req_str ) for req_str in req_strs ]
267
+ if any (req .marker is not None for req in reqs ):
268
+ msg = r"Markers not supported in `pytest_extra_requires`"
269
+ raise NotImplementedError (msg )
264
270
try :
265
- return get_version (req .name ) in req .specifier
271
+ return all ( get_version (req .name ) in req .specifier for req in reqs )
266
272
except PackageNotFoundError :
267
273
return False
268
274
You can’t perform that action at this time.
0 commit comments