(
self, scope: Union[Scope, "_ScopeName"]
)
| 733 | return lines |
| 734 | |
| 735 | def _getscopeitem( |
| 736 | self, scope: Union[Scope, "_ScopeName"] |
| 737 | ) -> Union[nodes.Item, nodes.Collector]: |
| 738 | if isinstance(scope, str): |
| 739 | scope = Scope(scope) |
| 740 | if scope is Scope.Function: |
| 741 | # This might also be a non-function Item despite its attribute name. |
| 742 | node: Optional[Union[nodes.Item, nodes.Collector]] = self._pyfuncitem |
| 743 | elif scope is Scope.Package: |
| 744 | # FIXME: _fixturedef is not defined on FixtureRequest (this class), |
| 745 | # but on FixtureRequest (a subclass). |
| 746 | node = get_scope_package(self._pyfuncitem, self._fixturedef) # type: ignore[attr-defined] |
| 747 | else: |
| 748 | node = get_scope_node(self._pyfuncitem, scope) |
| 749 | if node is None and scope is Scope.Class: |
| 750 | # Fallback to function item itself. |
| 751 | node = self._pyfuncitem |
| 752 | assert node, 'Could not obtain a node for scope "{}" for function {!r}'.format( |
| 753 | scope, self._pyfuncitem |
| 754 | ) |
| 755 | return node |
| 756 | |
| 757 | def __repr__(self) -> str: |
| 758 | return "<FixtureRequest for %r>" % (self.node) |
no test coverage detected