CodeVetter · Repo Unpack · Extension points
pytest-dev/pytest
pytest exposes explicit plugin contracts for nearly every stage of its lifecycle. Extensions can register options, supply collectors, generate parameters, replace execution, and consume or transform reports. Fixtures and typed stashes provide resource and state extension mechanisms. Configuration loaders and the public re-export module are additional integration boundaries that require compatibility review.
- Installable plugins advertise a pytest11 entry point, while local conftests and PYTEST_PLUGINS supply additional plugin modules; -p supports explicit enabling and disabling except for essential plugins.
- pytest_addhooks adds hook specifications, and historic pytest_plugin_registered calls provide both prior registrations and subsequent registrations to participating plugins.
- pytest_addoption registers argparse options and configuration values through parser.addoption and parser.addini; implementations receive Config values through getoption/getini, and conftest support is limited to initial conftests.
- Custom collection can implement pytest_collect_file and return File/Item subclasses constructed with from_parent; the test harness contains a concrete YAML collector example.
- pytest_generate_tests receives Metafunc; module and class implementations are included through call_extra, and populated callspecs become individually named Function items.
- Fixture registration accepts scope, parameters, IDs, autouse, and node visibility; execution passes through pytest_fixture_setup and invokes pytest_fixture_post_finalizer after other fixture finalizers.
- Report plugins consume pytest_runtest_logreport or customize pytest_report_teststatus; TerminalReporter uses the returned category, letter, and word, while LogXML registers as a report consumer outside xdist workers.
- StashKey provides unique typed plugin-state keys on Config or Node stashes; configuration parsing has centralized named and suffix loader registries, and pytest/__init__.py controls public exposure of extension types.