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
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.
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.

Enable beartype checking on all test functions by passing --beartype-tests to pytest.

# test_example.py
import pytest

def test_addition(a: int, b: int) -> int:
    return a + b

# Run with: pytest --beartype-tests