(self, argname: str)
| 645 | current = current._parent_request |
| 646 | |
| 647 | def _get_active_fixturedef(self, argname: str) -> FixtureDef[object]: |
| 648 | if argname == "request": |
| 649 | return RequestFixtureDef(self) |
| 650 | |
| 651 | # If we already finished computing a fixture by this name in this item, |
| 652 | # return it. |
| 653 | fixturedef = self._fixture_defs.get(argname) |
| 654 | if fixturedef is not None: |
| 655 | self._check_scope(fixturedef, fixturedef._scope) |
| 656 | return fixturedef |
| 657 | |
| 658 | # Find the appropriate fixturedef. |
| 659 | fixturedefs = self._arg2fixturedefs.get(argname, None) |
| 660 | if fixturedefs is None: |
| 661 | # We arrive here because of a dynamic call to |
| 662 | # getfixturevalue(argname) which was naturally |
| 663 | # not known at parsing/collection time. |
| 664 | fixturedefs = self._fixturemanager.getfixturedefs(argname, self._pyfuncitem) |
| 665 | # No fixtures defined with this name. |
| 666 | if fixturedefs is None: |
| 667 | raise FixtureLookupError(argname, self) |
| 668 | # The are no fixtures with this name applicable for the function. |
| 669 | if not fixturedefs: |
| 670 | raise FixtureLookupError(argname, self) |
| 671 | |
| 672 | # A fixture may override another fixture with the same name, e.g. a |
| 673 | # fixture in a module can override a fixture in a conftest, a fixture in |
| 674 | # a class can override a fixture in the module, and so on. |
| 675 | # An overriding fixture can request its own name (possibly indirectly); |
| 676 | # in this case it gets the value of the fixture it overrides, one level |
| 677 | # up. |
| 678 | # Check how many `argname`s deep we are, and take the next one. |
| 679 | # `fixturedefs` is sorted from furthest to closest, so use negative |
| 680 | # indexing to go in reverse. |
| 681 | index = -1 |
| 682 | for request in self._iter_chain(): |
| 683 | if request.fixturename == argname: |
| 684 | index -= 1 |
| 685 | # If already consumed all of the available levels, fail. |
| 686 | if -index > len(fixturedefs): |
| 687 | raise FixtureLookupError(argname, self) |
| 688 | fixturedef = fixturedefs[index] |
| 689 | |
| 690 | # Prepare a SubRequest object for calling the fixture. |
| 691 | try: |
| 692 | callspec = self._pyfuncitem.callspec |
| 693 | except AttributeError: |
| 694 | callspec = None |
| 695 | if callspec is not None and argname in callspec.params: |
| 696 | param = callspec.params[argname] |
| 697 | param_index = callspec.indices[argname] |
| 698 | # The parametrize invocation scope overrides the fixture's scope. |
| 699 | scope = callspec._arg2scope[argname] |
| 700 | else: |
| 701 | param = NOTSET |
| 702 | param_index = 0 |
| 703 | scope = fixturedef._scope |
| 704 | self._check_fixturedef_without_param(fixturedef) |
no test coverage detected