Skip to content

Commit 259cff5

Browse files
committed
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.
1 parent f695e18 commit 259cff5

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/_pytest/pytester.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,6 @@ def copy_example(self, name: Optional[str] = None) -> Path:
950950
f'example "{example_path}" is not found as a file or directory'
951951
)
952952

953-
Session = Session
954-
955953
def getnode(
956954
self, config: Config, arg: Union[str, "os.PathLike[str]"]
957955
) -> Optional[Union[Collector, Item]]:
@@ -1529,7 +1527,6 @@ class Testdir:
15291527

15301528
CLOSE_STDIN: "Final" = Pytester.CLOSE_STDIN
15311529
TimeoutExpired: "Final" = Pytester.TimeoutExpired
1532-
Session: "Final" = Pytester.Session
15331530

15341531
def __init__(self, pytester: Pytester, *, _ispytest: bool = False) -> None:
15351532
check_ispytest(_ispytest)

testing/python/collect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import _pytest._code
88
import pytest
99
from _pytest.config import ExitCode
10+
from _pytest.main import Session
1011
from _pytest.monkeypatch import MonkeyPatch
1112
from _pytest.nodes import Collector
1213
from _pytest.pytester import Pytester
@@ -294,7 +295,7 @@ def make_function(pytester: Pytester, **kwargs: Any) -> Any:
294295
from _pytest.fixtures import FixtureManager
295296

296297
config = pytester.parseconfigure()
297-
session = pytester.Session.from_config(config)
298+
session = Session.from_config(config)
298299
session._fixturemanager = FixtureManager(session)
299300

300301
return pytest.Function.from_parent(parent=session, **kwargs)

0 commit comments

Comments
 (0)