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

Function get_scope_node

src/_pytest/fixtures.py:132–148  ·  view source on GitHub ↗
(
    node: nodes.Node, scope: Scope
)

Source from the content-addressed store, hash-verified

130
131
132def get_scope_node(
133 node: nodes.Node, scope: Scope
134) -> Optional[Union[nodes.Item, nodes.Collector]]:
135 import _pytest.python
136
137 if scope is Scope.Function:
138 return node.getparent(nodes.Item)
139 elif scope is Scope.Class:
140 return node.getparent(_pytest.python.Class)
141 elif scope is Scope.Module:
142 return node.getparent(_pytest.python.Module)
143 elif scope is Scope.Package:
144 return node.getparent(_pytest.python.Package)
145 elif scope is Scope.Session:
146 return node.getparent(_pytest.main.Session)
147 else:
148 assert_never(scope)
149
150
151# Used for storing artificial fixturedefs for direct parametrization.

Callers 2

_getscopeitemMethod · 0.85

Calls 2

assert_neverFunction · 0.90
getparentMethod · 0.80

Tested by

no test coverage detected