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>`.
| 266 | @final |
| 267 | @dataclasses.dataclass |
| 268 | class 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 | |
| 296 | class LegacyTmpdirPlugin: |