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:
9494 a string. If not empty, the string value is used as the skip reason.
9595 pytest_extra_requires : dict
9696 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) }``,
9898 where the values are PEP 508 dependency specifiers. If a requirement is not met,
9999 the behavior is equivalent to using the ``--ignore=...`` command line switch for
100100 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):
8888 if fnmatch_ex (entry , collection_path ):
8989 return True
9090
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 ():
9292 if fnmatch_ex (entry , collection_path ):
93- return not is_req_satisfied (req_str )
93+ return not is_req_satisfied (reqs )
9494
9595
9696def is_private (item ):
Original file line number Diff line number Diff line change 1010import inspect
1111from contextlib import contextmanager
1212
13+ from typing import Sequence
14+
1315from importlib .metadata import version as get_version , PackageNotFoundError
1416from packaging .requirements import Requirement
1517
@@ -257,12 +259,16 @@ def get_public_objects(module, skiplist=None):
257259 return (items , names ), failures
258260
259261
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.
262264 """
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 )
264270 try :
265- return get_version (req .name ) in req .specifier
271+ return all ( get_version (req .name ) in req .specifier for req in reqs )
266272 except PackageNotFoundError :
267273 return False
268274
You can’t perform that action at this time.
0 commit comments