diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index c5da9f4cf43..5dc1aebcc22 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -27,10 +27,12 @@ def pytest_sessionstart(session): import _pytest.python + scopename2class.update({ 'class': _pytest.python.Class, 'module': _pytest.python.Module, 'function': _pytest.main.Item, + 'session': _pytest.main.Session, }) session._fixturemanager = FixtureManager(session) @@ -62,8 +64,6 @@ def provide(self): def get_scope_node(node, scope): cls = scopename2class.get(scope) if cls is None: - if scope == "session": - return node.session raise ValueError("unknown scope") return node.getparent(cls) diff --git a/changelog/2910.trivial b/changelog/2910.trivial new file mode 100644 index 00000000000..87bf00dfee5 --- /dev/null +++ b/changelog/2910.trivial @@ -0,0 +1 @@ +Internal refactoring to simplify scope node lookup.