MCPcopy
hub / github.com/pytest-dev/pytest / TempdirFactory

Class TempdirFactory

src/_pytest/legacypath.py:268–293  ·  view source on GitHub ↗

Backward compatibility wrapper that implements ``py.path.local`` for :class:`TempPathFactory`. .. note:: These days, it is preferred to use ``tmp_path_factory``. :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.

Source from the content-addressed store, hash-verified

266@final
267@dataclasses.dataclass
268class TempdirFactory:
269 """Backward compatibility wrapper that implements ``py.path.local``
270 for :class:`TempPathFactory`.
271
272 .. note::
273 These days, it is preferred to use ``tmp_path_factory``.
274
275 :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
276
277 """
278
279 _tmppath_factory: TempPathFactory
280
281 def __init__(
282 self, tmppath_factory: TempPathFactory, *, _ispytest: bool = False
283 ) -> None:
284 check_ispytest(_ispytest)
285 self._tmppath_factory = tmppath_factory
286
287 def mktemp(self, basename: str, numbered: bool = True) -> LEGACY_PATH:
288 """Same as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object."""
289 return legacy_path(self._tmppath_factory.mktemp(basename, numbered).resolve())
290
291 def getbasetemp(self) -> LEGACY_PATH:
292 """Same as :meth:`TempPathFactory.getbasetemp`, but returns a ``py.path.local`` object."""
293 return legacy_path(self._tmppath_factory.getbasetemp().resolve())
294
295
296class LegacyTmpdirPlugin:

Callers 1

pytest_configureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected