skillfed

pytest-cpp

Use pytest's runner to discover and execute C++ tests

pytest-cpp v2.6.0 277.3K downloads/30d#8,148 on PyPI147
Permissive license MIT Active released

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

uv

uv add pytest-cpp

poetry

poetry add pytest-cpp

Installing 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

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: C++Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: Testing

Tags

pytest C++ test runnerC++ test discovery pytestGoogle Test pytest integrationCatch2 pytest pluginmulti-language test executionC++ Boost.Test pytestunified test reporting C++
c++-testingmulti-language-projectstest-integration

More Testing packages