Skip to main content

Provide CMake module for Pytest

Project description

Pytest CMake

PyPi version CMake Test License

This project provides convenient ways to use Pytest within a CMake project. The package can be discovered from a specific range of versions on Linux, macOS or Windows using the find_package function:

find_package(Pytest 8.2.1 REQUIRED)

A pytest_discover_tests function is provided to simplify automatic testing for C++ projects with Python bindings. It can create CTest tests for each Python test collected within a controlled environment:

pytest_discover_tests(
    PythonTest
    LIBRARY_PATH_PREPEND
        $<TARGET_FILE_DIR:MyLibrary>
    PYTHON_PATH_PREPEND
        $<TARGET_FILE_DIR:MyLibrary>
    TRIM_FROM_NAME "^test_"
    DEPENDS MyLibrary
)

Running the tests will display the status for each test collected as follows:

    Start 1: PythonTest.greet_world
1/4 Test #1: PythonTest.greet_world ...........   Passed    0.47 sec
    Start 2: PythonTest.greet_john
2/4 Test #2: PythonTest.greet_john ............   Passed    0.47 sec
    Start 3: PythonTest.greet_julia
3/4 Test #3: PythonTest.greet_julia ...........   Passed    0.47 sec
    Start 4: PythonTest.greet_michael
4/4 Test #4: PythonTest.greet_michael .........   Passed    0.54 sec

Documentation

Full documentation, including installation and setup guides, can be found at https://python-cmake.github.io/pytest-cmake/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_cmake-1.3.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_cmake-1.3.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_cmake-1.3.0.tar.gz.

File metadata

  • Download URL: pytest_cmake-1.3.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_cmake-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6291881b85f8810068552ac9ccc5c9d74ecd3d0c59b395253905e82c930682b9
MD5 8c83d2d1a8b1cd923ff48cc5b2c3744d
BLAKE2b-256 b187d728546b63a4d115032c7bdd695f8217a914d9e2eee5bb2aedd973727c0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_cmake-1.3.0.tar.gz:

Publisher: release.yml on python-cmake/pytest-cmake

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_cmake-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_cmake-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_cmake-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 284eac42ce33a323255bdebafafd56f8525f4236cb91405acbc8a02caa45287b
MD5 5fd9fc4737db5e763cc1c604485b3ad1
BLAKE2b-256 8a240a06ffccafacdaf60305f58f7002be3eff5af9b1bbe2b710d09fcd522ec0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_cmake-1.3.0-py3-none-any.whl:

Publisher: release.yml on python-cmake/pytest-cmake

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page