Installs the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.
(config: Config)
| 438 | |
| 439 | @hookimpl |
| 440 | def pytest_configure(config: Config) -> None: |
| 441 | """Installs the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.""" |
| 442 | if config.pluginmanager.has_plugin("tmpdir"): |
| 443 | mp = MonkeyPatch() |
| 444 | config.add_cleanup(mp.undo) |
| 445 | # Create TmpdirFactory and attach it to the config object. |
| 446 | # |
| 447 | # This is to comply with existing plugins which expect the handler to be |
| 448 | # available at pytest_configure time, but ideally should be moved entirely |
| 449 | # to the tmpdir_factory session fixture. |
| 450 | try: |
| 451 | tmp_path_factory = config._tmp_path_factory # type: ignore[attr-defined] |
| 452 | except AttributeError: |
| 453 | # tmpdir plugin is blocked. |
| 454 | pass |
| 455 | else: |
| 456 | _tmpdirhandler = TempdirFactory(tmp_path_factory, _ispytest=True) |
| 457 | mp.setattr(config, "_tmpdirhandler", _tmpdirhandler, raising=False) |
| 458 | |
| 459 | config.pluginmanager.register(LegacyTmpdirPlugin, "legacypath-tmpdir") |
| 460 | |
| 461 | |
| 462 | @hookimpl |
nothing calls this directly
no test coverage detected