Resolve if each parametrized argument must be considered an indirect parameter to a fixture of the same name, or a direct parameter to the parametrized function, based on the ``indirect`` parameter of the parametrize() call. :param argnames: List of argument names passed to
(
argnames: Sequence[str],
indirect: bool | Sequence[str],
nodeid: str,
)
| 1612 | |
| 1613 | |
| 1614 | def _resolve_args_directness( |
| 1615 | argnames: Sequence[str], |
| 1616 | indirect: bool | Sequence[str], |
| 1617 | nodeid: str, |
| 1618 | ) -> dict[str, Literal["indirect", "direct"]]: |
| 1619 | """Resolve if each parametrized argument must be considered an indirect |
| 1620 | parameter to a fixture of the same name, or a direct parameter to the |
| 1621 | parametrized function, based on the ``indirect`` parameter of the |
| 1622 | parametrize() call. |
| 1623 | |
| 1624 | :param argnames: |
| 1625 | List of argument names passed to ``parametrize()``. |
| 1626 | :param indirect: |
| 1627 | Same as the ``indirect`` parameter of ``parametrize()``. |
| 1628 | :param nodeid: |
| 1629 | Node ID to which the parametrization is applied. |
| 1630 | :returns: |
| 1631 | A dict mapping each arg name to either "indirect" or "direct". |
| 1632 | """ |
| 1633 | arg_directness: dict[str, Literal["indirect", "direct"]] |
| 1634 | if isinstance(indirect, bool): |
| 1635 | arg_directness = dict.fromkeys(argnames, "indirect" if indirect else "direct") |
| 1636 | elif isinstance(indirect, Sequence): |
| 1637 | arg_directness = dict.fromkeys(argnames, "direct") |
| 1638 | for arg in indirect: |
| 1639 | if arg not in argnames: |
| 1640 | fail( |
| 1641 | f"In {nodeid}: indirect fixture '{arg}' doesn't exist", |
| 1642 | pytrace=False, |
| 1643 | ) |
| 1644 | arg_directness[arg] = "indirect" |
| 1645 | else: |
| 1646 | fail( |
| 1647 | f"In {nodeid}: expected Sequence or boolean for indirect, got {type(indirect).__name__}", |
| 1648 | pytrace=False, |
| 1649 | ) |
| 1650 | return arg_directness |
| 1651 | |
| 1652 | |
| 1653 | def _get_direct_parametrize_args(node: nodes.Node) -> set[str]: |
no outgoing calls
no test coverage detected