pytest-cpp


Namepytest-cpp JSON
Version 2.6.0 PyPI version JSON
download
home_pagehttp://github.com/pytest-dev/pytest-cpp
SummaryUse pytest's runner to discover and execute C++ tests
upload_time2024-09-18 00:08:08
maintainerNone
docs_urlNone
authorBruno Oliveira
requires_python>=3.8
licenseMIT
keywords pytest test unittest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
pytest-cpp
==========

|python| |version| |anaconda| |ci| |black|

Use `pytest <https://pypi.python.org/pypi/pytest>`_ runner to discover and execute C++ tests.

Supports `Google Test <https://code.google.com/p/googletest>`_,
`Boost.Test <http://www.boost.org/doc/libs/release/libs/test>`_,
and `Catch2 <https://github.com/catchorg/Catch2>`_:

.. |version| image:: http://img.shields.io/pypi/v/pytest-cpp.png
  :target: https://crate.io/packages/pytest-cpp

.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-cpp.svg
    :target: https://anaconda.org/conda-forge/pytest-cpp

.. |ci| image:: https://github.com/pytest-dev/pytest-cpp/workflows/test/badge.svg
    :target: https://github.com/pytest-dev/pytest-cpp/actions

.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-cpp.svg
    :target: https://pypi.python.org/pypi/pytest-cpp/
    :alt: Supported Python versions

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

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 <https://pypi.python.org/pypi/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.;

.. contents:: **Table of Contents**


Installation
============

Install using `pip <http://pip-installer.org/>`_:

.. code-block:: console

    $ pip install pytest-cpp

Usage
=====

.. code-block:: console

    $ 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:

.. code-block:: ini

    [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:

.. code-block:: ini

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

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

.. code-block:: console

    $ 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.

.. code-block:: ini

    [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:

.. code-block:: ini

    [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.

.. code-block:: ini

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

or

.. code-block:: ini

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

Changelog
=========

Please consult `CHANGELOG <https://github.com/pytest-dev/pytest-cpp/blob/master/CHANGELOG.md>`_.

Support
=======

All feature requests and bugs are welcome, so please make sure to add
feature requests and bugs to the
`issues <https://github.com/pytest-dev/pytest-cpp/issues>`_ page!

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/pytest-dev/pytest-cpp",
    "name": "pytest-cpp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "pytest test unittest",
    "author": "Bruno Oliveira",
    "author_email": "nicoddemus@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cf/a1/c2679d7ff2da20a0f89c7820ae2739cde739eac9b43c192531117b31b5f4/pytest_cpp-2.6.0.tar.gz",
    "platform": null,
    "description": "==========\npytest-cpp\n==========\n\n|python| |version| |anaconda| |ci| |black|\n\nUse `pytest <https://pypi.python.org/pypi/pytest>`_ runner to discover and execute C++ tests.\n\nSupports `Google Test <https://code.google.com/p/googletest>`_,\n`Boost.Test <http://www.boost.org/doc/libs/release/libs/test>`_,\nand `Catch2 <https://github.com/catchorg/Catch2>`_:\n\n.. |version| image:: http://img.shields.io/pypi/v/pytest-cpp.png\n  :target: https://crate.io/packages/pytest-cpp\n\n.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-cpp.svg\n    :target: https://anaconda.org/conda-forge/pytest-cpp\n\n.. |ci| image:: https://github.com/pytest-dev/pytest-cpp/workflows/test/badge.svg\n    :target: https://github.com/pytest-dev/pytest-cpp/actions\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-cpp.svg\n    :target: https://pypi.python.org/pypi/pytest-cpp/\n    :alt: Supported Python versions\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n\nThis brings several benefits:\n\n* Allows you to run all your tests in multi-language projects with a single\n  command;\n* Execute C++ tests in **parallel** using\n  `pytest-xdist <https://pypi.python.org/pypi/pytest-xdist>`_ plugin;\n* Use ``--junitxml`` option to produce a single and uniform xml file with all\n  your test suite results;\n* Filter which tests to run using standard test filtering capabilities, such as\n  by file names, directories, keywords by using the ``-k`` option, etc.;\n\n.. contents:: **Table of Contents**\n\n\nInstallation\n============\n\nInstall using `pip <http://pip-installer.org/>`_:\n\n.. code-block:: console\n\n    $ pip install pytest-cpp\n\nUsage\n=====\n\n.. code-block:: console\n\n    $ pytest\n\nOnce installed, pytest runs will search and run tests\nfound in **executable** files, detecting if the suites are\nGoogle, Boost, or Catch2 tests automatically.\n\nConfiguration Options\n~~~~~~~~~~~~~~~~~~~~~\n\nFollowing are the options that can be put in the pytest configuration file related\nto pytest-cpp.\n\ncpp_files\n^^^^^^^^^\n\nYou can configure which files are tested for suites by using the ``cpp_files``\nini configuration option:\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_files = test_suite*\n\nBy default matches ``test_*`` and ``*_test`` executable files.\n\ncpp_arguments\n^^^^^^^^^^^^^\n\nArguments to the C++ tests can be provided with the\n``cpp_arguments`` ini configuration option.\n\nFor example:\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_arguments =-v --log-dir=logs\n\nYou can change this option directly in the command-line using\npytest's ``-o`` option:\n\n.. code-block:: console\n\n    $ pytest -o cpp_arguments='-v --log-dir=logs'\n\n**Important**: do not pass filtering arguments (for example ``--gtest_filter``), as this will conflict\nwith the plugin functionality and behave incorrectly.\n\nTo filter tests, use the standard pytest filtering facilities (such as ``-k``).\n\ncpp_ignore_py_files\n^^^^^^^^^^^^^^^^^^^\n\nThis option defaults to ``True`` and configures the plugin to ignore ``*.py`` files that\nwould otherwise match the ``cpp_files`` option.\n\nSet it to ``False`` if you have C++ executable files that end with the ``*.py`` extension.\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_ignore_py_files = False\n\ncpp_harness\n^^^^^^^^^^^\n\nThis option allows the usage of tools that are used by invoking them on the console\nwrapping the test binary, like valgrind and memcheck:\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_harness = valgrind --tool=memcheck\n\n\ncpp_harness_collect\n^^^^^^^^^^^^^^^^^^^\n\nThis option allows the usage of tools or emulators (like wine or qemu) that are used by invoking them\non the console wrapping the test binary during a test collection.\n\nMight be used in the combination with ``cpp_harness`` to run a binary in emulators, like wine or qemu\nin cross-compilation targets.\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_harness_collect = qemu-x86_64 -L libs/\n\nor\n\n.. code-block:: ini\n\n    [pytest]\n    cpp_harness_collect = qemu-x86_64 -L libs/\n    cpp_harness = qemu-x86_64 -L libs/\n\nChangelog\n=========\n\nPlease consult `CHANGELOG <https://github.com/pytest-dev/pytest-cpp/blob/master/CHANGELOG.md>`_.\n\nSupport\n=======\n\nAll feature requests and bugs are welcome, so please make sure to add\nfeature requests and bugs to the\n`issues <https://github.com/pytest-dev/pytest-cpp/issues>`_ page!\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use pytest's runner to discover and execute C++ tests",
    "version": "2.6.0",
    "project_urls": {
        "Homepage": "http://github.com/pytest-dev/pytest-cpp"
    },
    "split_keywords": [
        "pytest",
        "test",
        "unittest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a44dc2f5d53165264ae5831f361fe7723c45da05718a97015b2eddc452cf503",
                "md5": "5212bc9b73ed86a76b49ded963c946f1",
                "sha256": "b33de94609450feea2fba9efff3558b8ac8f1fdf40a99e263b395d4798b911bb"
            },
            "downloads": -1,
            "filename": "pytest_cpp-2.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5212bc9b73ed86a76b49ded963c946f1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15074,
            "upload_time": "2024-09-18T00:08:06",
            "upload_time_iso_8601": "2024-09-18T00:08:06.415920Z",
            "url": "https://files.pythonhosted.org/packages/2a/44/dc2f5d53165264ae5831f361fe7723c45da05718a97015b2eddc452cf503/pytest_cpp-2.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfa1c2679d7ff2da20a0f89c7820ae2739cde739eac9b43c192531117b31b5f4",
                "md5": "b4cefff2c9aadf20e613673bda52259a",
                "sha256": "c2f49d3c038539ac84786a94d852e4f4619c34c95979c2bc69c20b3bdf051d85"
            },
            "downloads": -1,
            "filename": "pytest_cpp-2.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b4cefff2c9aadf20e613673bda52259a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 465490,
            "upload_time": "2024-09-18T00:08:08",
            "upload_time_iso_8601": "2024-09-18T00:08:08.251145Z",
            "url": "https://files.pythonhosted.org/packages/cf/a1/c2679d7ff2da20a0f89c7820ae2739cde739eac9b43c192531117b31b5f4/pytest_cpp-2.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-18 00:08:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pytest-dev",
    "github_project": "pytest-cpp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-cpp"
}
        
Elapsed time: 1.47428s