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

Function pytest_configure

src/_pytest/legacypath.py:439–458  ·  view source on GitHub ↗

Installs the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.

(config: Config)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

setattrMethod · 0.95
MonkeyPatchClass · 0.90
TempdirFactoryClass · 0.85
add_cleanupMethod · 0.80
registerMethod · 0.80

Tested by

no test coverage detected