pytest-cpp


Namepytest-cpp JSON
Version 2.5.0 PyPI version JSON
download
home_pagehttp://github.com/pytest-dev/pytest-cpp
SummaryUse pytest's runner to discover and execute C++ tests
upload_time2023-11-01 14:55:34
maintainer
docs_urlNone
authorBruno Oliveira
requires_python>=3.7
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": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "pytest test unittest",
    "author": "Bruno Oliveira",
    "author_email": "nicoddemus@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/72/6da4fd6ea5afd44e10dbed76ef666c0732e27317a753099bc163f3330a91/pytest-cpp-2.5.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.5.0",
    "project_urls": {
        "Homepage": "http://github.com/pytest-dev/pytest-cpp"
    },
    "split_keywords": [
        "pytest",
        "test",
        "unittest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32d5b7b5c75dc2e11555898fbec78f88970c43f27439436ac83e65de6afcd2c6",
                "md5": "000fda38d0999bee1470c45cd8125040",
                "sha256": "137bcaa6487307b4c362245fcd4abf35de64ee85e6375f4d06cd31e6a64f9701"
            },
            "downloads": -1,
            "filename": "pytest_cpp-2.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "000fda38d0999bee1470c45cd8125040",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15064,
            "upload_time": "2023-11-01T14:55:32",
            "upload_time_iso_8601": "2023-11-01T14:55:32.133179Z",
            "url": "https://files.pythonhosted.org/packages/32/d5/b7b5c75dc2e11555898fbec78f88970c43f27439436ac83e65de6afcd2c6/pytest_cpp-2.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0f726da4fd6ea5afd44e10dbed76ef666c0732e27317a753099bc163f3330a91",
                "md5": "0baa787e72869982d0a145e129012e97",
                "sha256": "695604baa21bc95291bb4ea7263a7aa960753de57c2d17d224c4652fbcf65cdc"
            },
            "downloads": -1,
            "filename": "pytest-cpp-2.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0baa787e72869982d0a145e129012e97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 465039,
            "upload_time": "2023-11-01T14:55:34",
            "upload_time_iso_8601": "2023-11-01T14:55:34.221452Z",
            "url": "https://files.pythonhosted.org/packages/0f/72/6da4fd6ea5afd44e10dbed76ef666c0732e27317a753099bc163f3330a91/pytest-cpp-2.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-01 14:55:34",
    "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: 0.14483s