Dynamically run a named fixture function. Declaring fixtures via function argument is recommended where possible. But if you can only decide whether to use another fixture at test setup time, you may use this function to retrieve it inside a fixture or test function
(self, argname: str)
| 578 | item.funcargs[argname] = self.getfixturevalue(argname) |
| 579 | |
| 580 | def getfixturevalue(self, argname: str) -> Any: |
| 581 | """Dynamically run a named fixture function. |
| 582 | |
| 583 | Declaring fixtures via function argument is recommended where possible. |
| 584 | But if you can only decide whether to use another fixture at test |
| 585 | setup time, you may use this function to retrieve it inside a fixture |
| 586 | or test function body. |
| 587 | |
| 588 | :raises pytest.FixtureLookupError: |
| 589 | If the given fixture could not be found. |
| 590 | """ |
| 591 | fixturedef = self._get_active_fixturedef(argname) |
| 592 | assert fixturedef.cached_result is not None |
| 593 | return fixturedef.cached_result[0] |
| 594 | |
| 595 | def _get_active_fixturedef( |
| 596 | self, argname: str |