MCPcopy
hub / github.com/pytest-dev/pytest / get_param_argkeys

Function get_param_argkeys

src/_pytest/fixtures.py:225–252  ·  view source on GitHub ↗

Return all ParamArgKeys for item matching the specified high scope.

(item: nodes.Item, scope: Scope)

Source from the content-addressed store, hash-verified

223
224
225def get_param_argkeys(item: nodes.Item, scope: Scope) -> Iterator[ParamArgKey]:
226 """Return all ParamArgKeys for item matching the specified high scope."""
227 assert scope is not Scope.Function
228
229 try:
230 callspec: CallSpec2 = item.callspec # type: ignore[attr-defined]
231 except AttributeError:
232 return
233
234 item_cls = None
235 if scope is Scope.Session:
236 scoped_item_path = None
237 elif scope is Scope.Package:
238 # Package key = module's directory.
239 scoped_item_path = item.path.parent
240 elif scope is Scope.Module:
241 scoped_item_path = item.path
242 elif scope is Scope.Class:
243 scoped_item_path = item.path
244 item_cls = item.cls # type: ignore[attr-defined]
245 else:
246 assert_never(scope)
247
248 for argname in callspec.indices:
249 if callspec._arg2scope[argname] != scope:
250 continue
251 param_index = callspec.indices[argname]
252 yield ParamArgKey(argname, param_index, scoped_item_path, item_cls)
253
254
255def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]:

Callers 1

reorder_itemsFunction · 0.85

Calls 2

assert_neverFunction · 0.90
ParamArgKeyClass · 0.85

Tested by

no test coverage detected