From 6ac25c7916e95159f8aa4f009de78afcdab767ec Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 25 Dec 2021 10:37:07 +0200 Subject: [PATCH] pytest: bring back direct imports of TempdirFactory, Testdir The monkeypatch approach doesn't work for `import pytest; pytest.TempdirFactory`. Fix #9432. --- src/_pytest/legacypath.py | 6 ------ src/pytest/__init__.py | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/_pytest/legacypath.py b/src/_pytest/legacypath.py index 743c06d55c4..8307f56e890 100644 --- a/src/_pytest/legacypath.py +++ b/src/_pytest/legacypath.py @@ -245,9 +245,6 @@ def __str__(self) -> str: return str(self.tmpdir) -pytest.Testdir = Testdir # type: ignore[attr-defined] - - class LegacyTestdirPlugin: @staticmethod @pytest.fixture @@ -284,9 +281,6 @@ def getbasetemp(self) -> LEGACY_PATH: return legacy_path(self._tmppath_factory.getbasetemp().resolve()) -pytest.TempdirFactory = TempdirFactory # type: ignore[attr-defined] - - class LegacyTmpdirPlugin: @staticmethod @pytest.fixture(scope="session") diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 9c284ac9615..777d3774064 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -23,6 +23,8 @@ from _pytest.fixtures import FixtureRequest from _pytest.fixtures import yield_fixture from _pytest.freeze_support import freeze_includes +from _pytest.legacypath import TempdirFactory +from _pytest.legacypath import Testdir from _pytest.logging import LogCaptureFixture from _pytest.main import Session from _pytest.mark import Mark @@ -142,7 +144,9 @@ "Stash", "StashKey", "version_tuple", + "TempdirFactory", "TempPathFactory", + "Testdir", "TestReport", "UsageError", "WarningsRecorder",