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

Method prune_dependency_tree

src/_pytest/fixtures.py:420–437  ·  view source on GitHub ↗

Recompute names_closure from initialnames and name2fixturedefs. Can only reduce names_closure, which means that the new closure will always be a subset of the old one. The order is preserved. This method is needed because direct parametrization may shadow some of th

(self)

Source from the content-addressed store, hash-verified

418 name2fixturedefs: dict[str, Sequence[FixtureDef[Any]]]
419
420 def prune_dependency_tree(self) -> None:
421 """Recompute names_closure from initialnames and name2fixturedefs.
422
423 Can only reduce names_closure, which means that the new closure will
424 always be a subset of the old one. The order is preserved.
425
426 This method is needed because direct parametrization may shadow some
427 of the fixtures that were included in the originally built dependency
428 tree. In this way the dependency tree can get pruned, and the closure
429 of argnames may get reduced.
430 """
431 closure = set(
432 traverse_fixture_closure(
433 self.initialnames,
434 getfixturedefs=self.name2fixturedefs.get,
435 )
436 )
437 self.names_closure[:] = (name for name in self.names_closure if name in closure)
438
439
440class FixtureRequest(abc.ABC):

Callers 1

_genfunctionsMethod · 0.80

Calls 1

traverse_fixture_closureFunction · 0.85

Tested by

no test coverage detected