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

Function pytest_configure

src/_pytest/legacypath.py:440–459  ·  view source on GitHub ↗

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

(config: Config)

Source from the content-addressed store, hash-verified

438
439@hookimpl
440def 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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected