Pytest plugin that applies @beartype to every collected test function.
Project Links
Meta
Author: Adam Dangoor
Requires Python: >=3.11
Classifiers
Development Status
- 4 - Beta
Framework
- Pytest
License
- OSI Approved :: MIT License
Programming Language
- Python :: 3 :: Only
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
A tiny pytest plugin that applies beartype to every collected test function, giving you runtime type-checking of test signatures and any locally-typed variables inside the test body.
This is distinct from pytest-beartype, which beartypes your source packages. This plugin beartypes the tests themselves.
Install
uv add --dev pytest-beartype-tests
The plugin auto-registers via the pytest11 entry point — there is no configuration.
What it does
Equivalent to writing this hook in your conftest.py:
import pytest
from beartype import beartype
def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
for item in items:
item.obj = beartype(obj=item.obj)