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-0.13.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pytest_cmake-0.13.0.tar.gz
Algorithm Hash digest
SHA256 9751fab8fe7baa08cd0bde2bc30a715644714771bb1eab145027471cc0db2c15
MD5 358b98ca8e87d3abe0d68da3fd4370aa
BLAKE2b-256 79f0ee0fcf1fb5b69992c8f7dd6a2f341b9a4c221678667d83ca731ac87d40e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_cmake-0.13.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.

Supported by

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