Skip to main content

Supported Python versions version anaconda ci black

Use pytest runner to discover and execute C++ tests.

Supports Google Test, Boost.Test, and Catch2:

This brings several benefits:

  • Allows you to run all your tests in multi-language projects with a single command;

  • Execute C++ tests in parallel using pytest-xdist plugin;

  • Use --junitxml option to produce a single and uniform xml file with all your test suite results;

  • Filter which tests to run using standard test filtering capabilities, such as by file names, directories, keywords by using the -k option, etc.;

Installation

Install using pip:

$ pip install pytest-cpp

Usage

$ pytest

Once installed, pytest runs will search and run tests found in executable files, detecting if the suites are Google, Boost, or Catch2 tests automatically.

Configuration Options

Following are the options that can be put in the pytest configuration file related to pytest-cpp.

cpp_files

You can configure which files are tested for suites by using the cpp_files ini configuration option:

[pytest]
cpp_files = test_suite*

By default matches test_* and *_test executable files.

cpp_arguments

Arguments to the C++ tests can be provided with the cpp_arguments ini configuration option.

For example:

[pytest]
cpp_arguments =-v --log-dir=logs

You can change this option directly in the command-line using pytest’s -o option:

$ pytest -o cpp_arguments='-v --log-dir=logs'

Important: do not pass filtering arguments (for example --gtest_filter), as this will conflict with the plugin functionality and behave incorrectly.

To filter tests, use the standard pytest filtering facilities (such as -k).

cpp_ignore_py_files

This option defaults to True and configures the plugin to ignore *.py files that would otherwise match the cpp_files option.

Set it to False if you have C++ executable files that end with the *.py extension.

[pytest]
cpp_ignore_py_files = False

cpp_harness

This option allows the usage of tools that are used by invoking them on the console wrapping the test binary, like valgrind and memcheck:

[pytest]
cpp_harness = valgrind --tool=memcheck

cpp_harness_collect

This option allows the usage of tools or emulators (like wine or qemu) that are used by invoking them on the console wrapping the test binary during a test collection.

Might be used in the combination with cpp_harness to run a binary in emulators, like wine or qemu in cross-compilation targets.

[pytest]
cpp_harness_collect = qemu-x86_64 -L libs/

or

[pytest]
cpp_harness_collect = qemu-x86_64 -L libs/
cpp_harness = qemu-x86_64 -L libs/

Changelog

Please consult CHANGELOG.

Support

All feature requests and bugs are welcome, so please make sure to add feature requests and bugs to the issues page!

Metadata

Release files for pytest-cpp 2.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-cpp 2.6.0
File Size Uploaded Provenance
pytest_cpp-2.6.0.tar.gz 465.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-cpp 2.6.0
File Interpreter ABI Platform
pytest_cpp-2.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 480.6 kB

Release files / pytest_cpp-2.6.0.tar.gz

Download URL pytest_cpp-2.6.0.tar.gz
Size 465.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c2f49d3c038539ac84786a94d852e4f4619c34c95979c2bc69c20b3bdf051d85
BLAKE2b-256 checksum
How to use checksums
cfa1c2679d7ff2da20a0f89c7820ae2739cde739eac9b43c192531117b31b5f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.10

Release files / pytest_cpp-2.6.0-py3-none-any.whl

Download URL pytest_cpp-2.6.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b33de94609450feea2fba9efff3558b8ac8f1fdf40a99e263b395d4798b911bb
BLAKE2b-256 checksum
How to use checksums
2a44dc2f5d53165264ae5831f361fe7723c45da05718a97015b2eddc452cf503
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.10

Security for pytest-cpp 2.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page