pytest-cmake is a Pytest plugin that integrates Pytest into the CMake build system, allowing `ctest` to discover and run Python tests defined in `CMakeLists.txt`. It extends Pytest with options to scan CMake build directories and manage test execution within a CMake context. The current version is 1.3.0, and the project maintains an active release cadence, with minor versions released every 1-2 months.
pip install pytest-cmakeNo compatibility data collected yet for this library.
This quickstart demonstrates how to programmatically invoke Pytest using `pytest.main()` while activating the `pytest-cmake` plugin's `--py_cmake` option. It shows that the plugin is correctly installed and its command-line arguments are recognized by Pytest. For actual integration with CMake tests, your `CMakeLists.txt` would need to use `find_package(Pytest)` and `pytest_add_test()`.
The plugin is now loaded automatically by Pytest. Interact with its features via Pytest command-line options (e.g., `--py_cmake`) or through CMake functions like `pytest_add_test()` within your `CMakeLists.txt`.
Ensure the argument provided to `--py_cmake` points to a valid, existing CMake build directory (the directory containing `CMakeCache.txt` and other CMake build artifacts).
Ensure `pytest-cmake` is installed in the Python environment that CMake is configured to use. CMake typically finds installed Python packages' modules automatically, but in complex environments, you might need to explicitly set `CMAKE_PREFIX_PATH` or `Python_FIND_PATH`.
Ensure the plugin is installed by running `pip install pytest-cmake` in the active Python environment. Verify `pytest --version` lists the plugin, or `pytest --help` shows `--py_cmake`.
Provide a correct path to an existing CMake build directory. This directory should typically contain `CMakeCache.txt` and other build artifacts generated by CMake.
Remove any `import pytest_cmake` statements. The plugin's functionality is exposed via Pytest command-line options (e.g., `--py_cmake`) or through CMake's `find_package(Pytest)` and `pytest_add_test()` functions.