MCPcopy Create free account
hub / github.com/pytest-dev/pytest / getfixturevalue

Method getfixturevalue

src/_pytest/fixtures.py:580–593  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 8

_fillfixturesMethod · 0.95
setupMethod · 0.80
pdb_envFunction · 0.80
pdblistMethod · 0.80
test_getfixturevalueMethod · 0.80
aFunction · 0.80
arg1Function · 0.80

Calls 1

Tested by 7

setupMethod · 0.64
pdb_envFunction · 0.64
pdblistMethod · 0.64
test_getfixturevalueMethod · 0.64
aFunction · 0.64
arg1Function · 0.64