From 259cff59f51e2d5d001dc4d139ec799bbe15be81 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 22 Oct 2021 12:11:13 +0300 Subject: [PATCH] Remove {pytester,testdir}.Session aliases This causes `Session` documentation to be rendered again in full under `pytester` and `testdir` in the API Reference. I tried but couldn't get sphinx to hide it. Since it's a pretty odd thing to have (should just use `pytest.Session`), and I couldn't find any plugin which uses this, let's just remove it. --- src/_pytest/pytester.py | 3 --- testing/python/collect.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 5aa2fad54..7bdbdcd46 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -950,8 +950,6 @@ class Pytester: f'example "{example_path}" is not found as a file or directory' ) - Session = Session - def getnode( self, config: Config, arg: Union[str, "os.PathLike[str]"] ) -> Optional[Union[Collector, Item]]: @@ -1529,7 +1527,6 @@ class Testdir: CLOSE_STDIN: "Final" = Pytester.CLOSE_STDIN TimeoutExpired: "Final" = Pytester.TimeoutExpired - Session: "Final" = Pytester.Session def __init__(self, pytester: Pytester, *, _ispytest: bool = False) -> None: check_ispytest(_ispytest) diff --git a/testing/python/collect.py b/testing/python/collect.py index 5f803f297..1c312e102 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -7,6 +7,7 @@ from typing import Dict import _pytest._code import pytest from _pytest.config import ExitCode +from _pytest.main import Session from _pytest.monkeypatch import MonkeyPatch from _pytest.nodes import Collector from _pytest.pytester import Pytester @@ -294,7 +295,7 @@ class TestFunction: from _pytest.fixtures import FixtureManager config = pytester.parseconfigure() - session = pytester.Session.from_config(config) + session = Session.from_config(config) session._fixturemanager = FixtureManager(session) return pytest.Function.from_parent(parent=session, **kwargs)