MCPcopy Create free account
hub / github.com/pytest-dev/pytest / Testdir

Class Testdir

src/_pytest/legacypath.py:41–254  ·  view source on GitHub ↗

Similar to :class:`Pytester`, but this class works with legacy legacy_path objects instead. All methods just forward to an internal :class:`Pytester` instance, converting results to `legacy_path` objects as necessary.

Source from the content-addressed store, hash-verified

39
40@final
41class Testdir:
42 """
43 Similar to :class:`Pytester`, but this class works with legacy legacy_path objects instead.
44
45 All methods just forward to an internal :class:`Pytester` instance, converting results
46 to `legacy_path` objects as necessary.
47 """
48
49 __test__ = False
50
51 CLOSE_STDIN: "Final" = Pytester.CLOSE_STDIN
52 TimeoutExpired: "Final" = Pytester.TimeoutExpired
53
54 def __init__(self, pytester: Pytester, *, _ispytest: bool = False) -> None:
55 check_ispytest(_ispytest)
56 self._pytester = pytester
57
58 @property
59 def tmpdir(self) -> LEGACY_PATH:
60 """Temporary directory where tests are executed."""
61 return legacy_path(self._pytester.path)
62
63 @property
64 def test_tmproot(self) -> LEGACY_PATH:
65 return legacy_path(self._pytester._test_tmproot)
66
67 @property
68 def request(self):
69 return self._pytester._request
70
71 @property
72 def plugins(self):
73 return self._pytester.plugins
74
75 @plugins.setter
76 def plugins(self, plugins):
77 self._pytester.plugins = plugins
78
79 @property
80 def monkeypatch(self) -> MonkeyPatch:
81 return self._pytester._monkeypatch
82
83 def make_hook_recorder(self, pluginmanager) -> HookRecorder:
84 """See :meth:`Pytester.make_hook_recorder`."""
85 return self._pytester.make_hook_recorder(pluginmanager)
86
87 def chdir(self) -> None:
88 """See :meth:`Pytester.chdir`."""
89 return self._pytester.chdir()
90
91 def finalize(self) -> None:
92 """See :meth:`Pytester._finalize`."""
93 return self._pytester._finalize()
94
95 def makefile(self, ext, *args, **kwargs) -> LEGACY_PATH:
96 """See :meth:`Pytester.makefile`."""
97 if ext and not ext.startswith("."):
98 # pytester.makefile is going to throw a ValueError in a way that

Callers 1

testdirMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected