pytest-bazel
raw JSON → 0.1.6 verified Fri May 01 auth: no python deprecated
A pytest plugin that collects and runs tests in Bazel workspaces. Currently at version 0.1.6 with no active maintenance; last release was in 2020. Works by integrating pytest with Bazel's test runner, enabling parallel execution and caching. Suitable for Python projects using Bazel as their build system.
pip install pytest-bazel Common errors
error ERROR: Bazel binary not found ↓
cause Bazel is not installed or not in PATH.
fix
Install Bazel (https://bazel.build) or add its location to PATH.
error ModuleNotFoundError: No module named 'pytest_bazel' ↓
cause pytest-bazel is not installed in the environment.
fix
Run
pip install pytest-bazel in the correct Python environment. Warnings
deprecated pytest-bazel is no longer actively maintained. Consider migrating to `rules_python` or `bazel_pytest`. ↓
fix Switch to `rules_python` integration with native pytest support, or use `pip install bazel_pytest` for an alternative.
gotcha The plugin requires that Bazel and Python are on PATH. Misconfiguration may lead to 'Bazel not found' errors. ↓
fix Ensure Bazel is installed and available in your shell environment.
Imports
- pytest_bazel wrong
import pytest_bazelcorrectpytest_bazel is a plugin; no direct import needed. Use `--bazel` flag with pytest.
Quickstart
# Ensure pytest-bazel is installed
# Add to BUILD file or run:
pytest --bazel --bazel-python=$(which python) tests/