pytest-cpp
Use pytest's runner to discover and execute C++ tests
What it is and what it does
pytest-cpp is a pytest plugin that bridges Python's test runner with C++ test frameworks, allowing you to discover and execute C++ tests using pytest's command-line interface and reporting tools. It automatically detects test binaries built with Google Test, Boost.Test, or Catch2, and integrates them into your pytest workflow.
The plugin lets you run mixed Python and C++ test suites with a single pytest command, apply pytest's standard filtering (like -k for keyword matching), generate unified JUnit XML reports, and parallelize C++ test execution using pytest-xdist. It supports configuration options for specifying which files to test, passing arguments to C++ test binaries, and wrapping test execution with tools like valgrind or emulators for cross-compilation scenarios.
Use it for:
- Run all tests in a multi-language project (Python and C++) with one pytest command.
- Generate a single JUnit XML report combining results from both Python and C++ test suites.
- Parallelize C++ test execution across multiple cores using pytest-xdist.
- Filter and select which C++ tests to run using pytest's standard -k keyword matching.
- Wrap C++ test execution with memory checkers (valgrind) or emulators (qemu) for testing in non-native environments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that discovers and runs C++ tests from Google Test, Boost.Test, and Catch2 frameworks using pytest's test runner and reporting infrastructure.
Yes. If you maintain a multi-language project with C++ and Python tests, this plugin eliminates the need for separate test runners and reporting pipelines. It has low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license. The only prerequisite is having compiled C++ test binaries; the plugin does not compile code itself.
Install
pytest-cpp on PyPI
pip
pip install pytest-cppuv
uv add pytest-cpppoetry
poetry add pytest-cppInstalling pytest-cpp
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with recent commits and stable production status.
License in practice
MIT license is permissive; you can use this in commercial and proprietary projects with minimal restrictions beyond retaining the license notice.
Quickstart
pip install pytest-cpp
Then run:
pytest
The plugin automatically detects and executes C++ test binaries (Google Test, Boost.Test, Catch2) in your project directory.
Requires compiled C++ test executables matching the naming pattern test_* or *_test to be present in the project; the plugin does not compile C++ code itself.
Verify before relying
- Whether the plugin works with C++ test frameworks beyond Google Test, Boost.Test, and Catch2.
- Performance characteristics when running large numbers of C++ tests in parallel with pytest-xdist.
- Compatibility with recent versions of Google Test, Boost.Test, and Catch2 frameworks.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 695 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 277,298/month — #8,148 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_cpp-2.6.0-py3-none-any.whl
Keywords: pytest, test, unittest
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-seleniumpytest-selenium is a pytest plugin that…
copyleft · top 15,000 on PyPI
pytest-parallelA pytest plugin that runs tests in parallel…
permissive · top 15,000 on PyPI
pytest-odoopytest-odoo is a pytest plugin that runs Odoo…
agpl · top 15,000 on PyPI
pytest-run-parallelA pytest plugin that runs test functions…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI
pytest-covA pytest plugin that measures code coverage…
permissive · top 1,000 on PyPI
pytest-incrementalpytest-incremental is a pytest plugin that…
permissive · top 15,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI
tdd-guard-pytestA pytest plugin that captures test results and…
permissive · top 15,000 on PyPI
pytest-slackA pytest plugin that sends test results to…
permissive · top 15,000 on PyPI