• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

pytest-cpp

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!

More Repositories

1

pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
Python
11,750
star
2

pytest-testinfra

Testinfra test your infrastructures
Python
2,359
star
3

pytest-mock

Thin-wrapper around the mock package for easier use with pytest
Python
1,804
star
4

pytest-cov

Coverage plugin for pytest.
Python
1,722
star
5

pytest-xdist

pytest plugin for distributed testing and loop-on-failures testing modes.
Python
1,421
star
6

pytest-asyncio

Asyncio support for pytest
Python
1,378
star
7

pytest-django

A Django plugin for pytest.
Python
1,350
star
8

pytest-bdd

BDD library for the py.test runner
Python
1,281
star
9

pluggy

A minimalist production ready plugin system
Python
1,235
star
10

pytest-html

Plugin for generating HTML reports for pytest results
Python
689
star
11

pyfakefs

Provides a fake file system that mocks the Python file system modules.
Python
635
star
12

pytest-randomly

🎲 Pytest plugin to randomly order tests and control random.seed
Python
600
star
13

pytest-flask

A set of pytest fixtures to test Flask applications
Python
483
star
14

pytest-qt

pytest plugin for Qt (PyQt5/PyQt6 and PySide2/PySide6) application testing
Python
401
star
15

pytest-rerunfailures

a pytest plugin that re-runs failed tests up to -n times to eliminate flakey failures
Python
373
star
16

pytest-factoryboy

factory_boy integration the pytest runner
Python
358
star
17

pytest-selenium

Plugin for running Selenium with pytest
Python
331
star
18

cookiecutter-pytest-plugin

A Cookiecutter template for pytest plugins πŸ’»
Python
292
star
19

pytest-splinter

pytest splinter and selenium integration for anyone interested in browser interaction in tests
Python
253
star
20

pytest-describe

Describe-style plugin for the pytest framework
Python
208
star
21

pytest-timeout

Python
206
star
22

pytest-subtests

unittest subTest() support and subtests fixture
Python
199
star
23

pytest-repeat

pytest plugin for repeating test execution
Python
168
star
24

pytest-order

pytest plugin that allows to customize the test execution order
Python
158
star
25

pytest-instafail

py.test plugin to show failures instantly
Python
135
star
26

unittest2pytest

helps rewriting Python `unittest` test-cases into `pytest` test-cases
Python
128
star
27

pytest-env

pytest plugin to set environment variables in pytest.ini or pyproject.toml file
Python
128
star
28

pytest-github-actions-annotate-failures

Pytest plugin to annotate failed tests with a workflow command for GitHub Actions
Python
127
star
29

pytest-xprocess

pytest external process plugin
Python
97
star
30

pytest-reportlog

Replacement for the --resultlog option, focused in simplicity and extensibility
Python
89
star
31

execnet

distributed Python deployment and communication
Python
78
star
32

pytest-variables

Plugin for providing variables to pytest tests/fixtures
Python
74
star
33

pytest-play

pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files
Python
68
star
34

py

Python development support library (note: maintenance only)
Python
67
star
35

pytest-print

pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout)
Python
67
star
36

pytest-messenger

Pytest-messenger report plugin for all popular messengers like: Slack, DingTalk, Telegram
Python
67
star
37

pytest-random-order

pytest plugin to randomise the order of tests with some control over the randomness
Python
65
star
38

pytest-forked

extracted --boxed from pytest-xdist to ensure backward compat
Python
62
star
39

pytest-mimesis

Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
Python
62
star
40

pytest-services

Collection of fixtures and utility functions to run service processes for your tests
Python
57
star
41

pytest-runner

Python
56
star
42

pytest-metadata

Plugin for accessing test session metadata
Python
56
star
43

apipkg

Python
55
star
44

iniconfig

Python
50
star
45

pytest-twisted

test twisted code with pytest
Python
46
star
46

pytest-freezer

Pytest plugin providing a fixture interface for spulec/freezegun
Python
45
star
47

pytest-incremental

py-test plugin: an incremental test runner
Python
42
star
48

pytest-stress

A Pytest plugin that allows you to loop tests for a user defined amount of time.
Python
41
star
49

nose2pytest

Scripts to convert Python Nose tests to PyTest
Python
38
star
50

pytest-base-url

pytest plugin for URL based tests
Python
38
star
51

pytest-faker

faker integration the pytest test runner
Python
38
star
52

pytest-fixture-tools

Pytest fixture tools
Python
36
star
53

pytest-cloud

Distributed tests planner plugin for pytest testing framework.
Python
35
star
54

plugincompat

Test execution and compatibility checks for pytest plugins
CSS
34
star
55

pytest-faulthandler

py.test plugin that activates the fault handler module during testing
Python
27
star
56

pytest-localserver

py.test plugin to test server connections locally. This repository was migrated from Bitbucket.
Python
23
star
57

pygments-pytest

A pygments lexer for pytest output
Python
23
star
58

pytest-echo

pytest plugin to dump environment variables, package version and generic attributes.
Python
22
star
59

pytest-inline

pytest-inline is a pytest plugin for writing inline tests.
Python
16
star
60

pytest-nunit

An Nunit output plugin for Pytest
Python
10
star
61

pytest-plus

pytest-plus adds new features to pytest
Python
10
star
62

design

Graphic design for Pytest project
9
star
63

pytest-iam

A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite
Python
7
star
64

sprint

pytest development sprint 2024
7
star
65

pytest-bpdb

pytest plugin for dropping to bpdb on test failures
Python
6
star
66

blog.pytest.org

Repository for the official pytest blog
Python
4
star
67

pytest-tcpclient

pytest mocking of TCP clients
Python
3
star
68

regendoc

Python
2
star
69

meta

Used for generic pytest organization issues, stuff that can impact multiple projects.
2
star
70

pytest-libfaketime

Prepare pytest for python-libfaketime - https://github.com/simon-weber/python-libfaketime
Python
2
star
71

pytest-talks

public pytest talks and workshops - meant to help user groups spin up talks and workshops
HTML
1
star