Skip to content

Commit

Permalink
pytest: bring back direct imports of TempdirFactory, Testdir
Browse files Browse the repository at this point in the history
The monkeypatch approach doesn't work for `import pytest;
pytest.TempdirFactory`.

Fix pytest-dev#9432.
  • Loading branch information
bluetech committed Dec 25, 2021
1 parent 0fecfff commit 6ac25c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/_pytest/legacypath.py
Expand Up @@ -245,9 +245,6 @@ def __str__(self) -> str:
return str(self.tmpdir)


pytest.Testdir = Testdir # type: ignore[attr-defined]


class LegacyTestdirPlugin:
@staticmethod
@pytest.fixture
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions src/pytest/__init__.py
Expand Up @@ -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
Expand Down Expand Up @@ -142,7 +144,9 @@
"Stash",
"StashKey",
"version_tuple",
"TempdirFactory",
"TempPathFactory",
"Testdir",
"TestReport",
"UsageError",
"WarningsRecorder",
Expand Down

0 comments on commit 6ac25c7

Please sign in to comment.