pytest-beartype-tests
raw JSON → 2026.4.26 verified Sat May 09 auth: no python
A Pytest plugin that automatically applies @beartype to every collected test function at runtime, enabling runtime type-checking of test arguments and return values. The current version is 2026.04.26, with a rapid release cadence tied to calendar dates.
pip install pytest-beartype-tests Common errors
error ModuleNotFoundError: No module named 'beartype' ↓
cause Missing beartype dependency
fix
pip install beartype
error pytest: error: unrecognized arguments: --beartype-tests ↓
cause Plugin not installed or not activated in pytest
fix
Install pytest-beartype-tests via pip; ensure it's in the same environment.
Warnings
gotcha Automatic application of @beartype may slow down test collection for large test suites. ↓
fix Use --beartype-tests-skip to selectively disable for certain directories.
gotcha The plugin applies beartype to ALL collected test functions, including fixtures and conftest hooks, which can cause unexpected failures if those functions lack annotations. ↓
fix Ensure all test functions have appropriate type annotations or use @beartype.skip on specific functions.
Imports
- pytest_beartype_tests wrong
from pytest_beartype_tests import *correctimport pytest_beartype_tests
Quickstart
# test_example.py
import pytest
def test_addition(a: int, b: int) -> int:
return a + b
# Run with: pytest --beartype-tests