pax_global_header00006660000000000000000000000064151260575220014517gustar00rootroot0000000000000052 comment=785b5fb5cda4b6af069e153506af0d156ccc2788 python-cmake-pytest-cmake-702cb04/000077500000000000000000000000001512605752200170455ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/.github/000077500000000000000000000000001512605752200204055ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/.github/workflows/000077500000000000000000000000001512605752200224425ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/.github/workflows/docs-deploy.yml000066400000000000000000000022121512605752200254040ustar00rootroot00000000000000name: docs-deploy on: push: tags: - "*" workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: "pages" cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.x" - name: Create Build Environment run: | python -m pip install --upgrade pip python -m pip install -r ${GITHUB_WORKSPACE}/doc/requirements.txt mkdir -p ${{runner.workspace}}/build - name: Build documentation run: | sphinx-build -T -E -b html \ "${GITHUB_WORKSPACE}/doc" \ "${{runner.workspace}}/build" - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ${{runner.workspace}}/build deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 python-cmake-pytest-cmake-702cb04/.github/workflows/release.yml000066400000000000000000000026271512605752200246140ustar00rootroot00000000000000name: PyPi Release on: push: tags: - "*" permissions: contents: read jobs: pypi-publish: if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest environment: release permissions: id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install build twine - name: Build package run: | python -m build - name: Check metadata run: twine check dist/* - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 github-release: runs-on: ubuntu-latest name: GitHub release environment: release permissions: contents: write steps: - uses: actions/checkout@v4 - name: Get release version id: get_version uses: actions/github-script@v7 with: script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - name: Create GitHub release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: name: "v${{ steps.get_version.outputs.version }}" body: "Notes: https://python-cmake.github.io/pytest-cmake/release/release_notes.html" python-cmake-pytest-cmake-702cb04/.github/workflows/test.yml000066400000000000000000000047501512605752200241520ustar00rootroot00000000000000name: tests on: push: branches: [ main ] pull_request: branches: [ main ] # Run tests once a week on Sunday. schedule: - cron: "0 6 * * 0" jobs: run-tests: strategy: fail-fast: false matrix: pytest: [ "8", "9" ] cmake: [ "3.20", "4.2" ] os: [ "ubuntu", "macos", "windows" ] python: [ "3.10", "3.14" ] bundled: [ false, true ] name: | v${{ matrix.pytest }}-${{ matrix.cmake }} [${{ matrix.os }}-py${{ matrix.python }}] ${{ matrix.bundled && '(bundled)' || '' }} runs-on: "${{ matrix.os }}-latest" steps: - uses: actions/setup-python@v5 with: python-version: "${{ matrix.python }}" - uses: actions/checkout@v4 - name: Setup CMake uses: jwlawson/actions-setup-cmake@v2.0 if: ${{matrix.os != 'windows' || matrix.cmake != '3.20'}} with: cmake-version: "${{ matrix.cmake }}.x" - name: Setup CMake (Bump up CMake minimal version for Visual Studio 17 2022) uses: jwlawson/actions-setup-cmake@v2.0 if: ${{matrix.os == 'windows' && matrix.cmake == '3.20'}} with: # Visual Studio 17 2022 requires at least CMake 3.21. # https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2017%202022.html cmake-version: "3.21.x" - name: Setup Environment shell: bash run: | cmake --version python -m pip install --upgrade pip python -m pip install nanobind==2.* python -m pip install . pytest==${{ matrix.pytest }}.* - name: Build and Run Unit Tests shell: bash run: | cmake -S ./test -B ./test/build cmake --build ./test/build ctest --test-dir ./test/build -VV -C Release - name: Configure Example shell: bash env: BUNDLE_PYTHON_TESTS: ${{ matrix.bundled }} run: | cmake \ -D "CMAKE_BUILD_TYPE=Release" \ -D "nanobind_ROOT=$(python -m nanobind --cmake_dir)" \ -S ./example \ -B ./build - name: Build without Python and Test shell: bash working-directory: build run: | cmake --build . --target foo CppTest --config Release ctest -VV -C Release -R "CppTest" - name: Build and Test shell: bash working-directory: build run: | cmake --build . --config Release ctest -VV -C Release python-cmake-pytest-cmake-702cb04/.gitignore000066400000000000000000000011621512605752200210350ustar00rootroot00000000000000# cmake artifacts CMakeLists.txt.user CMakeCache.txt CMakeFiles CMakeScripts Testing Makefile cmake_install.cmake cmake-build-*/ install_manifest.txt compile_commands.json CTestTestfile.cmake # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # virtualenv venv/ ENV/ # Caches Thumbs.db # Development .project .pydevproject .settings .idea/ .history/ # Unit test / coverage reports htmlcov/ .coverage .coverage.* .cache *,cover .pytest_cache/ python-cmake-pytest-cmake-702cb04/.versup.json000066400000000000000000000007271512605752200213500ustar00rootroot00000000000000{ "files": { "pyproject.toml": [ [ "version = \"([\\d\\.]+)\"", "version = \"[version]\"" ] ], "doc/release/release_notes.rst": [ [ ".. release:: Upcoming", ".. release:: [version]\n :date: [version_date]" ] ] }, "changelog": { "enabled": false }, "commit": { "mainbranch": "main" } }python-cmake-pytest-cmake-702cb04/LICENSE000066400000000000000000000020611512605752200200510ustar00rootroot00000000000000MIT License Copyright (c) 2022 Jeremy Retailleau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.python-cmake-pytest-cmake-702cb04/README.md000066400000000000000000000037351512605752200203340ustar00rootroot00000000000000# Pytest CMake [![PyPi version](https://img.shields.io/pypi/v/pytest-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/pytest-cmake) [![CMake](https://img.shields.io/badge/CMake-3.20...4.2-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org) [![Test](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) This project provides convenient ways to use [Pytest](https://docs.pytest.org/) within a [CMake](https://cmake.org/) project. The package can be discovered from a specific range of versions on Linux, macOS or Windows using the [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) function: ```cmake 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: ```cmake pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ TRIM_FROM_NAME "^test_" DEPENDS MyLibrary ) ``` Running the tests will display the status for each test collected as follows: ```console 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/ python-cmake-pytest-cmake-702cb04/build_config.py000066400000000000000000000024121512605752200220420ustar00rootroot00000000000000from hatchling.builders.hooks.plugin.interface import BuildHookInterface import pathlib class BuildConfig(BuildHookInterface): """Builder to create and share pytest config.""" def initialize(self, version, build_data): """Execute builder.""" root = pathlib.Path(__file__).parent.resolve() build_path = (root / "build") build_path.mkdir(parents=True, exist_ok=True) # CMake search procedure is limited to CMake package configuration files # and does not work with modules. Hence, we are generating a # configuration file based on the CMake modules created. # https://cmake.org/cmake/help/latest/command/find_package.html config_path = (build_path / "PytestConfig.cmake") with config_path.open("w", encoding="utf-8") as stream: stream.write( "include(${CMAKE_CURRENT_LIST_DIR}/FindPytest.cmake)\n" ) # Always accept; actual version checks are handled by FindPytest.cmake config_path = (build_path / "PytestConfigVersion.cmake") with config_path.open("w", encoding="utf-8") as stream: stream.write( "set(PACKAGE_VERSION_COMPATIBLE TRUE)\n" "set(PACKAGE_VERSION_EXACT TRUE)\n" ) python-cmake-pytest-cmake-702cb04/cmake/000077500000000000000000000000001512605752200201255ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/cmake/FindPytest.cmake000066400000000000000000000134121512605752200232210ustar00rootroot00000000000000# Discover required Pytest target. # # This module defines the following imported targets: # Pytest::Pytest # # It also exposes the 'pytest_discover_tests' function, which adds CTest # test for each Pytest test. The "BUNDLE_PYTHON_TESTS" environment variable # can be used to run all discovered tests together. # # Usage: # find_package(Pytest) # find_package(Pytest REQUIRED) # find_package(Pytest 4.6.11 REQUIRED) # # Note: # The Pytest_ROOT environment variable or CMake variable can be used to # prepend a custom search path. # (https://cmake.org/cmake/help/latest/policy/CMP0074.html) cmake_minimum_required(VERSION 3.20...4.2) include(FindPackageHandleStandardArgs) find_program(PYTEST_EXECUTABLE NAMES pytest) mark_as_advanced(PYTEST_EXECUTABLE) if(PYTEST_EXECUTABLE) execute_process( COMMAND "${PYTEST_EXECUTABLE}" --version OUTPUT_VARIABLE _version ERROR_VARIABLE _version OUTPUT_STRIP_TRAILING_WHITESPACE ) if (_version MATCHES "pytest (version )?([0-9]+\\.[0-9]+\\.[0-9]+)") set(PYTEST_VERSION "${CMAKE_MATCH_2}") endif() endif() find_package_handle_standard_args( Pytest REQUIRED_VARS PYTEST_EXECUTABLE VERSION_VAR PYTEST_VERSION HANDLE_COMPONENTS HANDLE_VERSION_RANGE ) if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) add_executable(Pytest::Pytest IMPORTED) set_target_properties(Pytest::Pytest PROPERTIES IMPORTED_LOCATION "${PYTEST_EXECUTABLE}") # Function to discover pytest tests and add them to CTest. function(pytest_discover_tests NAME) set(_BOOL_ARGS STRIP_PARAM_BRACKETS INCLUDE_FILE_PATH BUNDLE_TESTS ) set(_SINGLE_VALUE_ARGS WORKING_DIRECTORY TRIM_FROM_NAME TRIM_FROM_FULL_NAME ) set(_MULTI_VALUE_ARGS TEST_PATHS LIBRARY_PATH_PREPEND PYTHON_PATH_PREPEND ENVIRONMENT PROPERTIES DEPENDS EXTRA_ARGS DISCOVERY_EXTRA_ARGS ) cmake_parse_arguments( PARSE_ARGV 1 "" "${_BOOL_ARGS}" "${_SINGLE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ) # Set platform-specific library path environment variable. if (CMAKE_SYSTEM_NAME STREQUAL Windows) set(LIBRARY_ENV_NAME PATH) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(LIBRARY_ENV_NAME DYLD_LIBRARY_PATH) else() set(LIBRARY_ENV_NAME LD_LIBRARY_PATH) endif() # Convert paths to CMake-friendly format. if(DEFINED ENV{${LIBRARY_ENV_NAME}}) cmake_path(CONVERT "$ENV{${LIBRARY_ENV_NAME}}" TO_CMAKE_PATH_LIST LIBRARY_PATH) else() set(LIBRARY_PATH "") endif() if(DEFINED ENV{PYTHONPATH}) cmake_path(CONVERT "$ENV{PYTHONPATH}" TO_CMAKE_PATH_LIST PYTHON_PATH) else() set(PYTHON_PATH "") endif() # Prepend specified paths to the library and Python paths. if (_LIBRARY_PATH_PREPEND) list(REVERSE _LIBRARY_PATH_PREPEND) foreach (_path ${_LIBRARY_PATH_PREPEND}) set(LIBRARY_PATH "${_path}" "${LIBRARY_PATH}") endforeach() endif() if (_PYTHON_PATH_PREPEND) list(REVERSE _PYTHON_PATH_PREPEND) foreach (_path ${_PYTHON_PATH_PREPEND}) set(PYTHON_PATH "${_path}" "${PYTHON_PATH}") endforeach() endif() # Set default working directory if none is specified. if (NOT _WORKING_DIRECTORY) set(_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endif() get_filename_component(_WORKING_DIRECTORY "${_WORKING_DIRECTORY}" REALPATH) # Override option by environment variable if available. if (DEFINED ENV{BUNDLE_PYTHON_TESTS}) set(_BUNDLE_TESTS $ENV{BUNDLE_PYTHON_TESTS}) endif() # Define file paths for generated CMake include files. set(_include_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_include.cmake") set(_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_tests.cmake") add_custom_command( VERBATIM OUTPUT "${_tests_file}" DEPENDS ${_DEPENDS} COMMAND ${CMAKE_COMMAND} -D "PYTEST_EXECUTABLE=${PYTEST_EXECUTABLE}" -D "TEST_PATHS=${_TEST_PATHS}" -D "TEST_GROUP_NAME=${NAME}" -D "BUNDLE_TESTS=${_BUNDLE_TESTS}" -D "LIBRARY_ENV_NAME=${LIBRARY_ENV_NAME}" -D "LIBRARY_PATH=${LIBRARY_PATH}" -D "PYTHON_PATH=${PYTHON_PATH}" -D "TRIM_FROM_NAME=${_TRIM_FROM_NAME}" -D "TRIM_FROM_FULL_NAME=${_TRIM_FROM_FULL_NAME}" -D "STRIP_PARAM_BRACKETS=${_STRIP_PARAM_BRACKETS}" -D "INCLUDE_FILE_PATH=${_INCLUDE_FILE_PATH}" -D "WORKING_DIRECTORY=${_WORKING_DIRECTORY}" -D "ENVIRONMENT=${_ENVIRONMENT}" -D "TEST_PROPERTIES=${_PROPERTIES}" -D "CTEST_FILE=${_tests_file}" -D "EXTRA_ARGS=${_EXTRA_ARGS}" -D "DISCOVERY_EXTRA_ARGS=${_DISCOVERY_EXTRA_ARGS}" -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PytestAddTests.cmake") # Create a custom target to run the tests. add_custom_target(${NAME} ALL DEPENDS ${_tests_file}) file(WRITE "${_include_file}" "if(EXISTS \"${_tests_file}\")\n" " include(\"${_tests_file}\")\n" "else()\n" " add_test(${NAME}_NOT_BUILT ${NAME}_NOT_BUILT)\n" "endif()\n" ) # Register the include file to be processed for tests. set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${_include_file}") endfunction() endif() python-cmake-pytest-cmake-702cb04/cmake/PytestAddTests.cmake000066400000000000000000000143011512605752200240520ustar00rootroot00000000000000# Wrapper used to create individual CTest tests from Pytest tests. cmake_minimum_required(VERSION 3.20...4.2) if(CMAKE_SCRIPT_MODE_FILE) # Initialize content for the CMake test file. set(_content "") # Convert library and Python paths to native format. cmake_path(CONVERT "${LIBRARY_PATH}" TO_NATIVE_PATH_LIST LIBRARY_PATH) cmake_path(CONVERT "${PYTHON_PATH}" TO_NATIVE_PATH_LIST PYTHON_PATH) # Serialize path values separated by semicolons (required on Windows). string(REPLACE [[;]] [[\\;]] LIBRARY_PATH "${LIBRARY_PATH}") string(REPLACE [[;]] [[\\;]] PYTHON_PATH "${PYTHON_PATH}") # Set up the encoded environment with required paths. set(ENCODED_ENVIRONMENT "${LIBRARY_ENV_NAME}=${LIBRARY_PATH}" "PYTHONPATH=${PYTHON_PATH}" ) # Serialize additional environment variables if any are provided. foreach(env ${ENVIRONMENT}) string(REPLACE [[;]] [[\\;]] env "${env}") list(APPEND ENCODED_ENVIRONMENT "${env}") endforeach() # Handle EXTRA_ARGS for individual tests if(BUNDLE_TESTS) list(PREPEND EXTRA_ARGS ${DISCOVERY_EXTRA_ARGS}) endif() set(EXTRA_ARGS_WRAPPED) foreach(arg IN LISTS EXTRA_ARGS) list(APPEND EXTRA_ARGS_WRAPPED "[==[${arg}]==]") endforeach() list(JOIN EXTRA_ARGS_WRAPPED " " EXTRA_ARGS_STR) # Macro to create individual tests with optional test properties. macro(create_test NAME IDENTIFIERS) string(APPEND _content "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\"") foreach(identifier ${IDENTIFIERS}) string(APPEND _content " [==[${identifier}]==]") endforeach() string(APPEND _content " ${EXTRA_ARGS_STR} )\n") # Prepare the properties for the test, including the environment settings. set(args "PROPERTIES ENVIRONMENT [==[${ENCODED_ENVIRONMENT}]==]") # Add working directory string(APPEND args " WORKING_DIRECTORY [==[${WORKING_DIRECTORY}]==]") # Append any additional properties, escaping complex characters if necessary. foreach(property ${TEST_PROPERTIES}) if(property MATCHES "[^-./:a-zA-Z0-9_]") string(APPEND args " [==[${property}]==]") else() string(APPEND args " ${property}") endif() endforeach() # Append the test properties to the content. string(APPEND _content "set_tests_properties([==[${NAME}]==] ${args})\n") endmacro() # If tests are bundled together, create a single test group. if (BUNDLE_TESTS) create_test("\${TEST_GROUP_NAME}" "\${TEST_PATHS}") else() # Set environment variables for collecting tests. set(ENV{${LIBRARY_ENV_NAME}} "${LIBRARY_PATH}") set(ENV{PYTHONPATH} "${PYTHON_PATH}") set(ENV{PYTHONWARNINGS} "ignore") set(_command "${PYTEST_EXECUTABLE}" --collect-only -q "--rootdir=${WORKING_DIRECTORY}" ${DISCOVERY_EXTRA_ARGS} ) foreach(test_path IN LISTS TEST_PATHS) list(APPEND _command "${test_path}") endforeach() # Collect tests. execute_process( COMMAND ${_command} OUTPUT_VARIABLE _output_lines ERROR_VARIABLE _output_lines OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ${WORKING_DIRECTORY} ) # Check for errors during test collection. string(REGEX MATCH "(=+ ERRORS =+|ERROR:).*" _error "${_output_lines}") if (_error) message(${_error}) message(FATAL_ERROR "An error occurred during the collection of Python tests.") endif() # Convert the collected output into a list of lines. string(REPLACE [[;]] [[\;]] _output_lines "${_output_lines}") string(REPLACE "\n" ";" _output_lines "${_output_lines}") # Regex pattern to identify pytest test identifiers. set(test_pattern "([^:]+)\.py(::([^:]+))?::([^:]+)") # Iterate through each line to identify and process tests. foreach(line ${_output_lines}) string(REGEX MATCHALL ${test_pattern} matching "${line}") # Skip lines that are not identified as tests. if (NOT matching) continue() endif() # Extract file, class, and function names from the test pattern. set(_file ${CMAKE_MATCH_1}) set(_class ${CMAKE_MATCH_3}) set(_func ${CMAKE_MATCH_4}) # Optionally trim parts of the class or function name. if (TRIM_FROM_NAME) string(REGEX REPLACE "${TRIM_FROM_NAME}" "" _class "${_class}") string(REGEX REPLACE "${TRIM_FROM_NAME}" "" _func "${_func}") endif() # Form the test name using class and function. if (_class) set(test_name "${_class}.${_func}") else() set(test_name "${_func}") endif() # Optionally strip parameter brackets from the test name. if (STRIP_PARAM_BRACKETS) string(REGEX REPLACE "\\[(.+)\\]$" ".\\1" test_name "${test_name}") endif() # Optionally include the file path in the test name. if (INCLUDE_FILE_PATH) cmake_path(CONVERT "${_file}" TO_CMAKE_PATH_LIST _file) string(REGEX REPLACE "/" "." _file "${_file}") set(test_name "${_file}.${test_name}") endif() # Optionally trim parts of the full test name. if (TRIM_FROM_FULL_NAME) string(REGEX REPLACE "${TRIM_FROM_FULL_NAME}" "" test_name "${test_name}") endif() # Prefix the test name with the test group name. set(test_name "${TEST_GROUP_NAME}.${test_name}") set(test_case "${line}") # Create the test for CTest. create_test("\${test_name}" "\${test_case}") endforeach() # Warn if no tests were discovered. if(NOT _content) message(WARNING "No Python tests have been discovered.") endif() endif() # Write the generated test content to the specified CTest file. file(WRITE ${CTEST_FILE} ${_content}) endif() python-cmake-pytest-cmake-702cb04/doc/000077500000000000000000000000001512605752200176125ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/doc/_extensions/000077500000000000000000000000001512605752200221505ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/doc/_extensions/changelog.py000066400000000000000000000055461512605752200244630ustar00rootroot00000000000000from datetime import datetime from docutils import nodes from docutils.parsers.rst import directives from sphinx.util.docutils import SphinxDirective class ReleaseDirective(SphinxDirective): has_content = True required_arguments = 1 optional_arguments = 0 option_spec = { "date": directives.unchanged_required } def run(self): """Creates a section for release notes with version and date.""" version = self.arguments[0] # Fetch today's date as default if no date is provided today_date_str = datetime.now().strftime("%Y-%m-%d") date_str = self.options.get("date", today_date_str) try: parsed_date = datetime.strptime(date_str, "%Y-%m-%d") release_date = parsed_date.strftime("%e %B %Y") except ValueError: raise ValueError(f"Invalid date format: {date_str}") # Create the version title node version_node = nodes.strong(text=version) section_title = nodes.title("", "", version_node) # Create the section node with a specific ID section_id = f"release-{version.replace(' ', '-')}" section = nodes.section( "", section_title, ids=[section_id], classes=["changelog-release"] ) # Append formatted date section.append( nodes.emphasis(text=release_date, classes=["release-date"]) ) # Parse content into a list of changes content_node = nodes.Element() self.state.nested_parse(self.content, self.content_offset, content_node) # Create a bullet list of changes changes_list = nodes.bullet_list("", classes=["changelog-change-list"]) for child in content_node: item = nodes.list_item("") item.append(child) changes_list.append(item) section.append(changes_list) return [section] class ChangeDirective(SphinxDirective): has_content = True required_arguments = 1 optional_arguments = 0 def run(self): """Generates a categorized list item for a changelog entry.""" category = self.arguments[0] # Create a paragraph for the category with specific styling class_name = f"changelog-category-{category.lower().replace(' ', '-')}" category_node = nodes.inline( "", category, classes=["changelog-category", class_name] ) paragraph_node = nodes.paragraph("", "", category_node) # Parse the detailed content under the category content_node = nodes.container() self.state.nested_parse(self.content, 0, content_node) paragraph_node += content_node return [paragraph_node] def setup(app): """Register extension with Sphinx.""" app.add_directive("release", ReleaseDirective) app.add_directive("change", ChangeDirective) python-cmake-pytest-cmake-702cb04/doc/_extensions/github_user.py000066400000000000000000000010641512605752200250430ustar00rootroot00000000000000from docutils import nodes from sphinx.util.docutils import SphinxRole class GitHubUserRole(SphinxRole): def run(self): username = self.text.strip() url = f"https://github.com/{username}" node = nodes.reference(rawtext=self.rawtext, text=f"@{username}", refuri=url, **self.options) return [node], [] def setup(app): """Register extension with Sphinx.""" app.add_role('github_user', GitHubUserRole()) return { 'version': '1.0', 'parallel_read_safe': True, 'parallel_write_safe': True, } python-cmake-pytest-cmake-702cb04/doc/_static/000077500000000000000000000000001512605752200212405ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/doc/_static/style.css000066400000000000000000000023551512605752200231170ustar00rootroot00000000000000.changelog-release { position: relative; } .changelog-release > h1, h2, h3, h4, h5 { margin-bottom: 5px; } .changelog-release em.release-date { color: #999; position: absolute; line-height: 2.5em; top: 0; right: 0; } .changelog-release ul.changelog-change-list { list-style: outside none none; } .changelog-release ul.changelog-change-list > li { list-style: outside none none; position: relative; margin: 0; padding: 8px 0 2px 120px; border-top: 1px solid #D6D6D6; } .rst-content .section .changelog-change-list ul li { list-style: initial; } .changelog-category { border-right: 3px solid #CCC; box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05), 0px -1px 0px rgba(0, 0, 0, 0.05) inset; color: #333; display: inline-block; font-size: 0.7em; font-style: normal; font-weight: bold; line-height: 14px; padding: 4px 2px 4px 10px; text-shadow: 1px 1px 0px #FFF; text-transform: uppercase; width: 102px; position: absolute; top: 10px; left: 0px; background-color: #f8f8f8; } .changelog-category-fixed { border-color: #7C0; } .changelog-category-new { border-color: #11B0E9; } .changelog-category-changed { border-color: #EB3F3F; } python-cmake-pytest-cmake-702cb04/doc/api_reference.rst000066400000000000000000000166641512605752200231500ustar00rootroot00000000000000.. _api_reference: ************* API Reference ************* .. highlight:: cmake .. function:: pytest_discover_tests(NAME ARGV) Automatically create :term:`CTest` tests for Python tests collected with :term:`Pytest` within a controlled environment:: pytest_discover_tests(NAME [TEST_PATHS path1 path2...] [WORKING_DIRECTORY dir] [TRIM_FROM_NAME pattern] [TRIM_FROM_FULL_NAME pattern] [LIBRARY_PATH_PREPEND path1 path2...] [PYTHON_PATH_PREPEND path1 path2...] [ENVIRONMENT env1 env2...] [PROPERTIES prop1 prop2...] [DEPENDS target1 target2...] [INCLUDE_FILE_PATH] [STRIP_PARAM_BRACKETS] [BUNDLE_TESTS] [EXTRA_ARGS arg1 arg2...] [DISCOVERY_EXTRA_ARGS arg1 arg2...] ) The options are: * ``NAME`` Indicate the name of the target that will be created. It will also be used as a prefix for each test created, or as an identifier the bundled test. * ``TEST_PATHS`` Specifies a list of files or directories to search when executing :term:`Pytest` from the current source directory (or from the ``WORKING_DIRECTORY`` value if provided):: pytest_discover_tests( ... TEST_PATHS path1 path2/test.py ) * ``WORKING_DIRECTORY`` Specify the directory in which to run the :term:`Pytest` command. If this option is not provided, the current source directory is used. * ``INCLUDE_FILE_PATH`` Include the file path of each collected :term:`Pytest` test into its generated test name. This helps distinguish tests with the same class or function names by including their source file for clearer identification:: pytest_discover_tests( ... INCLUDE_FILE_PATH ) * ``TRIM_FROM_NAME`` Specify a :term:`regular expression` to trim part of each class, method and function name discovered before creating the test. This option can be used to trim the convention prefix required by :term:`Pytest` for discovery:: pytest_discover_tests( ... TRIM_FROM_NAME "^(Test|test_)" ) * ``TRIM_FROM_FULL_NAME`` Specify a :term:`regular expression` to trim parts of the full test name generated:: pytest_discover_tests( ... TRIM_FROM_FULL_NAME "(Test|test_)" ) * ``STRIP_PARAM_BRACKETS`` Remove square brackets added to the test identifier when using :term:`parametrized tests `:: pytest_discover_tests( ... STRIP_PARAM_BRACKETS ) Tests identifiers will be reformatted as follows: - `test.foo[bar]` becomes `test.foo.bar` - `test.foo[1-3]` becomes `test.foo.1-3` - `test.foo[bar[nested]]` becomes `test.foo.bar[nested]` * ``LIBRARY_PATH_PREPEND`` List of library paths to prepend to the corresponding environment variable (:envvar:`LD_LIBRARY_PATH` on Linux, :envvar:`DYLD_LIBRARY_PATH` on macOS, and :envvar:`PATH` on Windows) when running the tests. Each path can be defined literally or as a CMake expression generator for convenience:: pytest_discover_tests( ... LIBRARY_PATH_PREPEND $ $ /path/to/libs/ ) * ``PYTHON_PATH_PREPEND`` List of Python paths to prepend to the :envvar:`PYTHONPATH` environment variable when running the tests. Each path can be defined literally or as a CMake expression generator for convenience:: pytest_discover_tests( ... PYTHON_PATH_PREPEND $ $ /path/to/python/ ) * ``ENVIRONMENT`` List of custom environment variables with associated values to set when running the tests:: pytest_discover_tests( ... ENVIRONMENT "ENV_VAR1=VALUE1" "ENV_VAR2=VALUE2" "ENV_VAR3=VALUE3" ) * ``PROPERTIES`` List of custom `test properties `_ to apply for all generated tests:: pytest_discover_tests( ... PROPERTIES LABELS "python;unit" TIMEOUT 120 ) * ``DEPENDS`` List of dependent targets that need to be executed before running the tests:: pytest_discover_tests( ... DEPENDS lib1 lib2 ) The Python files containing :term:`Pytest` tests can also be explicitly set as dependencies, ensuring that the target rebuilds whenever these files are modified:: pytest_discover_tests( ... DEPENDS /path/to/test_foo.py /path/to/test_bar.py ) For convenience, you can use the `GLOB_RECURSE `_ command to dynamically gather all test files:: file(GLOB_RECURSE test_files "/path/to/tests/*.py") pytest_discover_tests( ... DEPENDS ${test_files} ) * ``BUNDLE_TESTS`` Indicate whether Python tests should be bundled under a single :term:`CTest` test. This option can also be set dynamically by using the :envvar:`BUNDLE_PYTHON_TESTS` environment variable. Bundled tests generally run faster because :term:`Pytest` can use caching and :term:`fixtures ` with a broader scope. * ``EXTRA_ARGS`` List of extra arguments to pass on the :term:`Pytest` command line for each test case:: pytest_discover_tests( ... EXTRA_ARGS "--capture=no" "--cmdopt=demo" ) .. seealso:: `Pytest Command-Line Flags `_ * ``DISCOVERY_EXTRA_ARGS`` List of extra arguments to pass on the :term:`Pytest` command line for the test discovery:: pytest_discover_tests( ... DISCOVERY_EXTRA_ARGS "-k=expression" ) .. seealso:: `Pytest Command-Line Flags `_ .. warning:: This option may affect test discovery. Some arguments can change output format and break the test collection logic. Use with caution! .. note:: This function works similarly to the `gtest_discover_tests `_ function, which creates :term:`CTest` tests for each :term:`GTest` tests discovered within a single C++ executable test file. python-cmake-pytest-cmake-702cb04/doc/conf.py000066400000000000000000000022171512605752200211130ustar00rootroot00000000000000# -*- coding: utf-8 -*- """Documentation build configuration file.""" import re import pathlib import sys root = pathlib.Path(__file__).parent.resolve() sys.path.insert(0, str(root / "_extensions")) # -- General ------------------------------------------------------------------ # Extensions. extensions = ["changelog", "github_user", "sphinx.ext.intersphinx"] # The suffix of source filenames. source_suffix = ".rst" # The master toctree document. master_doc = "index" # General information about the project. project = u"Pytest CMake" copyright = u"2022, Jeremy Retailleau" # Version pattern = r"version = \"([\d\\.]+)\"" config = (root.parent / "pyproject.toml").read_text(encoding="utf-8") version = re.search(pattern, config, re.DOTALL).group(1) release = version # -- HTML output -------------------------------------------------------------- html_theme = "sphinx_rtd_theme" html_favicon = "favicon.ico" html_static_path = ["_static"] html_css_files = ["style.css"] html_copy_source = True # -- Intersphinx -------------------------------------------------------------- intersphinx_mapping = { "python": ("https://docs.python.org/3", None), } python-cmake-pytest-cmake-702cb04/doc/environment_variables.rst000066400000000000000000000017321512605752200247430ustar00rootroot00000000000000.. _environment_variables: ********************* Environment variables ********************* Environment variables directly defined or referenced by this package. .. envvar:: BUNDLE_PYTHON_TESTS Environment variable used to dynamically set a value for the ``BUNDLE_TESTS`` argument of the :func:`pytest_discover_tests` function. .. envvar:: CMAKE_PREFIX_PATH Environment variable (or :term:`CMake` option) used to locate directory to look for configurations. .. seealso:: https://cmake.org/cmake/help/latest/envvar/CMAKE_PREFIX_PATH.html .. envvar:: LD_LIBRARY_PATH Environment variable used on Linux/UNIX System to locate shared libraries. .. envvar:: DYLD_LIBRARY_PATH Environment variable used on macOS System to locate shared libraries. .. envvar:: PATH Environment variable used to specifies the directories to be searched to find a command. On Windows system, this environment variable is also used to locate shared libraries. python-cmake-pytest-cmake-702cb04/doc/favicon.ico000066400000000000000000000353561512605752200217470ustar00rootroot0000000000000000 Ј%6  Јо% h†6(0` $џџџ џџџOџџџЋџџџъџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџёџџџЙџџџ`џџџџџџ1џџџЉџџџђџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџјџџџМџџџEџџџџџџџџџRџџџоџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџьџџџoџџџџџџOџџџщџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџіџџџoџџџџџџ*џџџзџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџыџџџFџџџџџџ™џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџМџџџџџџ:џџџшџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџїџџџaџџџ‹џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЙџџџЫџџџџџџџџџџџџџџџџџџџџяэъџЮЩПџЬЧНџЭЧНџЭЧНџЭШОџЯЩПџаЪРџаЪСџбЫСџбЫСџбЫТџаЪТџаЪСџаЪСџбЫТџбЫТџбЫТџбЪТџаЩСџаЩСџаЪСџЯЩРџЯЩРџаЩРџаЩРџаЩРџаЩРџаЩПџЯЩПџЯЩПџЮЩПџЮШПџЬЧОџжбЩџњњљџџџџџџџџџџџџџџџџџџџџџџџџ№џџџыџџџџџџџџџџџџџџџџџџџџ˜ŽyџH4 џO<џO;џP;џQ:џR;џQ;џR<џR<џR;џS;џS;џS;џR:џR;џR;џR;џR:џQ9џQ9џQ:џQ:џQ:џR:џR;џR;џR;џQ:џR:џR:џR:џQ:џN7џO9џШСИџџџџџџџџџџџџџџџџџџџџџџџџџџџџ§џџџџџџџџџџџџџџџџџџџџЇžџI3 џЉŸџвЭХџаЫТџаЫТџаЫТџаЫТџаЫТџаЫТџаЫТџаЫТџаЫТџбЫУџбЬХџгЮЦџЬЦНџХОГџЦПДџЯЩРџдЮЦџбЬФџаЫТџаЫТџаЫСџаЫСџаЫСџаЫСџаЫСџаЫСџаЫСџаЫТџвЬФџŒ}hџP9џгЭЦџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџыщцџiV8џ†v\џњљјџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџѓёяџЖЋœџmTџlZ=џn\?џ‰w^џРЖЇџїієџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџчфрџdN1џ‘‚oџ§§§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџМЕЉџQ;џУЛ­џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџъчфџ{kSџ=N8џ1‚€џ1œ џ/џ3‚xџAL.џ‘„hџїѕѓџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўў§џ—‰wџ[F(џрмзџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџїїіџpXџr^@џђ№эџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ™‹yџ8ZIџ(Фоџрџџтџџрћџ* Ћџ/›џCP2џФЛЌџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџдЯШџU> џЊŸ‘џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџйдЭџYE#џЎЃџџџџџџџџџџџџџџџџџџџџџџџџџџџџџѕѓђџl]Aџ.œЂџнџџлџџоџџмљџ'‰’џ$КЩџ2ufџЈšˆџџџџџџџџџџџџџџџџџџџџџџџџџџџџџљљјџ„s]џq^Eџђ№юџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџž’€џaK)џфркџџџџџџџџџџџџџџџџџђ№юџНЕЉџŽzџVC!џ.ЄЎџоџџм§џ"ЉКџ$Œ‘џ&Ž’џ(‘џ5Q<џt^CџЈœŠџвЫТџ§ќћџџџџџџџџџџџџџџџџџТЛАџS<џЦОЕџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџцуоџ`M+џ•‡nџ§ќћџџџџџџџџџёяэџ†t[џdI"џ‚e<џYCџ.ЄЎџпџџм§џ&›Їџ+trџ+vuџ-vuџ.xuџ.yrџ3gZџKK,џИЎџџџџџџџџџџџџџ№юыџo[?џƒs]џњљљџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџБЈ˜џT>џЬХЙџџџџџџџџџЊŸџhK$џНžuџЪ­ƒџjT-џ.ЁЋџнџџлўџоџџпџџпџџпџџпџџпџџмћџ)Ѕ­џUU7џойбџџџџџџџџџЇ›ˆџXAџжвЪџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџѓђяџubFџzgIџїієџіѕєџr_Dџ™|UџаБŠџЬЎ†џuZ1џ3|џ#лўџмџџнџџоџџпџџоџџмџџнџџоџџнћџ2k_џЃ•‚џџџџџплеџ]F#џœ|џўўўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЪФКџX@џРЗЈџъчфџeP1џБ•mџаБ‰џЯА‰џЄ‡_џLG&џ3џ,œЇџ-œЇџ-›Іџ*œІџ&­Рџв№џлџџмџџрџџ+‚€џ„s]џќћћџ”„oџfQ2џшцтџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџќќќџ‘ƒnџfS2џгЮХџhS4џЏ’jџаБ‰џЮЏˆџЬЎ†џЋŽeџƒjAџ~gAџ}hAџ}hAџ|e>џ\O*џ5ocџ Ююџлџџоџџ-}zџ‰xdџЮШПџWA!џМВЇџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџплеџXC"џ—ŠtџyiOџsMџаБ‰џЮЏˆџЯЏˆџаБ‰џаА‰џбАˆџбЏˆџаА‰џЯАˆџК›qџ\J!џ)ЄАџнџџ!жіџ7`RџŸ‘€џyhPџ|kRџїїѕџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ •‚џZD"џ’†oџ_H%џД—pџЯА‰џаБŠџбБŠџбВ‹џвБŠџвБŠџаАˆџЯЏ‡џаЏˆџ{a7џ.”•џ оџџ.™ЁџXN5џ•ˆuџR;џЫХМџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџэышџkW;џ{jMџ‡{dџ]E џ~c=џ‹oIџ‹oIџŒnHџ‹nHџŒnHџИ™rџаА‰џЯА‰џ~e:џ7^Jџ2kbџMG/џœ}џaL/џlџќћћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџПЗЋџX>џСИЊџРЙЎџ”‰wџR<џmT.џ„jEџ„hDџ„gBџЕ—pџЯА‰џЯБ‰џ}b:џo\AџІ™‰џгЭФџœzџ`H)џтпйџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџјјїџƒqYџvbDџєђяџєѓёџkY;џŸ…]џЄ‰fџЋkџбВ‹џЯА‰џЮЏˆџЯБ‰џy]5џІœ‹џџџџџлжаџ[C%џ­Ђ’џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџигЫџXB џЊž‹џ§§ќџ‡ycџw\6џ’vRџЃ‡cџаВŠџЯБŠџаБŠџЙšsџaG џТМБџњњњџpZџs_Eџђ№юџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўўўџšzџ[D!џплвџидЭџaM0џqV0џЃ†`џЖ™pџГ–oџ—zRџbFџ…u^џіѕєџНЖЊџO8џТЛАџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџшхсџeO0џ~bџќћњџйеЯџ‡ydџ`K*џ]Eџ^E!џiU6џЂ—…џ№яьџюьщџiU8џ‚rZџљјїџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЙАЂџX?џЬФЕџџџџџќћћџшцтџидЭџлзбџ№юыџџџўџџџџџЃ˜†џYC"џйеЮџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџїієџmSџva>џђ№ыџџџџџџџџџџџџџџџџџџџџџџџџџпмжџ[F'џЃ—†џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџдЮХџYAџВІџџџџџџџџџџџџџџџџџџџџџќћћџŒiџgU8џьъчџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ§§ќџ•ˆrџ`J$џрлгџџџџџџџџџџџџџџџџџЦПЕџQ;џКВЅџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџхтнџ`M+џ‹|aџћњљџџџџџџџџџёяэџn[@џzgNџієѓџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџБЉšџS<џЯЩОџџџџџџџџџЎЃ•џS;џЯЪСџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџєѓ№џxgLџ{jNџіѕѓџцупџcK/џ•†rџ§§ќџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЯЩРџT?џГЊ›џ—‰uџcL-џцуоџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџќћћџ‰zeџP9џO7џЎЃ”џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџчџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџнйгџkX:џ{kSџюьщџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџСџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№юыџѓђ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџщџџџ|џџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЊџџџ,џџџоџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџёџџџOџџџƒџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЈџџџ џџџџџџУџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџнџџџ2џџџ6џџџзџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџщџџџSџџџ6џџџФџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџиџџџNџџџџџџџџџ„џџџпџџџ§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџщџџџ™џџџ)џџџџџџ,џџџ|џџџТџџџчџџџћџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ§џџџьџџџЫџџџ‹џџџ:џџџўј№рР€€€€€Рр№јџ( @ џџџ0џџџœџџџшџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџюџџџЈџџџ<џџџџџџџџџZџџџмџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџцџџџmџџџџџџWџџџяџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџіџџџmџџџџџџ(џџџеџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџфџџџ=џџџ‰џџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЈџџџдџџџџџџџџџџџџщцтџебШџеаЧџеаЧџжбЩџзвЩџзвЪџзвЪџзбЪџзбЪџзвЪџзвЪџзбЪџзбЩџжбЩџжбЩџжбЩџзбЩџзбЩџжбШџжбШџеаЩџзвЫџёяьџџџџџџџџџџџџџџџџэџџџіџџџџџџџџ§§ќџˆ{aџeT2џ}nTџ}mRџ~mSџ~nSџ~nSџ~mTџmTџnUџpXџ€oVџ€nVџ€oXџ~mVџ}lTџ~mTџ~mTџ~mSџ}mRџ~lSџ~mUџ_K-џІ›‹џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџГЊ›џ‚sXџё№эџјјіџјїіџјїіџјїіџјїіџљјїџюычџЗЌžџ†rџ“ŠvџНДІџёюыџљјїџјїіџјїіџјїѕџјїіџљјїџцтоџvcJџЯЩРџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџєѓёџqXџСЙЋџџџџџџџџџџџџџџџџџџџџџїѕѓџ‰‡vџ7€|џ*ЉГџ+ЄЉџ=qbџœ˜ƒџ§ќћџџџџџџџџџџџџџџџџџџџџџЅ™‰џ”‡tџ§§ќџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЮШПџ€oTџ№эщџџџџџџџџџџџџџџџџџбЩПџ?yqџйњџсџџФмџ&ІџVxfџюштџџџџџџџџџџџџџџџџџплеџygOџуплџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ§§§џ–‰sџЋ џџџџџџџџџђ№юџЎЃ‘џjLџ7„€џпџџ"ДШџ'€‚џ*~џ?\Jџ}~kџМЖЈџќћњџџџџџќќћџ“„pџЎЃ•џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџплеџwfGџпквџџџџџЅ˜…џsJџž~Tџ;…€џоџџаэџРзџ РиџТйџЙЬџ>|qџХПВџџџџџЪУЗџ}lRџ№юьџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЉžŒџ–‡pџьъцџƒmOџХІ~џКšqџKjWџ$СлџЮэџЯюџдєџоџџсџџМЮџƒrџђяьџ‚pVџУЛЏџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№юыџpVџДЋœџ…oOџЩЊƒџЭЎ‡џ„\џlqTџhx`џhw_џVq[џ+ ЊџмџџУлџq{kџАЅ•џlџњљљџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџРИЌџxgJџ~lNџЕ–oџвВ‹џвВ‹џаЏ‡џа­…џЮЌ„џП›pџWkQџвёџ)ЅВџ{taџxfMџлжЯџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџјјіџ‹|eџ}lQџ}fEџ™}Wџ ‚\џЁƒ]џЃ„]џУЄ|џЮ­…џkhFџ0†…џ]o`џyfMџЁ”‚џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџзвЪџ|hMџХПГџ–‹xџpW2џ‘vQџ›~YџТЃ|џЬ­†џ}eAџАЇ™џНВІџ|iPџъшфџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЁ”џЃ–‚џеаШџ|dAџ˜|XџЧЉƒџвГŒџЛœtџƒnOџъшфџŒ|gџЛВЅџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџщцтџxeIџЮЧЛџЃ—†џx`=џ“vNџtMџzb@џОЕЉџМДЇџqZџіѕѓџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЙАЁџ‹z^џѓёюџгЮЦџБЇ˜џЖЌžџплеџыщхџziOџЯЩРџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџїіѕџ‰x]џНГЁџџџџџџџџџџџџџџџџџІœŠџ™Œyџўў§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџвЬТџ{iIџъчсџџџџџџџџџлзаџwfKџфсмџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўў§џ™wџž‘{џџџџџћњљџŒ|fџ­Ђ’џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџцуоџziMџмзаџЩТИџlTџёяэџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџДЋœџ€oVџ{iOџШРЖџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџѓџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџђёюџ€oVџlџњљјџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЭџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџєђ№џіѕѓџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџчџџџ}џџџ§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ›џџџџџџЪџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџлџџџ1џџџFџџџфџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџяџџџ[џџџFџџџЫџџџ§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўџџџжџџџWџџџџџџџџџ}џџџЯџџџєџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџіџџџеџџџ‰џџџ(№рР€€€Ррј(  џџџџџџjџџџтџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџцџџџsџџџ џџџfџџџ№џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџєџџџsџџџйўў§џчхрџрмеџснжџснзџснзџфпкџупкџснзџсмжџрмжџрмжџъчуџџџџџџџџхџџџќљљїџŸ”џИАЁџУМЏџУМАџЛВЅџ‘Œzџ“Ž|џМГІџУЛАџУМАџДЊœџЇ›‹џ§§§џџџџџџџџџџџџџЯЩРџЭЧМџџџџџџ§§џЅЙГџ2ВРџ8š›џЕМВџџџџџџџџџХНГџзвЫџџџџџџџџџџџџџџџџџљјїџЕЌœџщцсџСАџeˆwџЪхџ ЉЙџBžЁџАФОџцсмџЙЏЂџќќћџџџџџџџџџџџџџџџџџџџџџокгџЋЁџ­“qџœ•tџQЂ џDЈЌџШтџTЈЌџБЃ“џхтмџџџџџџџџџџџџџџџџџџџџџџџџџџўўџВЈ™џz[џВ”nџГ’jџИ˜oџQˆџ^ƒzџПДЈџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџышфџЇ›‰џ˜‡nџ€ZџИ™qџЃ—џЉŽџёяьџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЪУИџДЉ˜џА ŠџЕІџДЊ›џбЫТџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџієђџЖЋšџ№юыџыщцџЖ­ŸџљјїџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџигЪџРИЋџНГЇџойгџџџџџџџџџџџџџџџџџџџџџџџџџџџџќџџџџџџџџџџџџџџџџџџџџ§§ќџВЈ˜џИЏЁџџўўџџџџџџџџџџџџџџџџџџџџџџџџџџџџдџџџџџџџџџџџџџџџџџџџџџџџџїіѕџјїіџџџџџџџџџџџџџџџџџџџџџџџџџџџџсџџџ]џџџьџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ№џџџjџџџџџџ]џџџжџџџќџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ§џџџкџџџfџџџР€€Рpython-cmake-pytest-cmake-702cb04/doc/glossary.rst000066400000000000000000000042151512605752200222110ustar00rootroot00000000000000******** Glossary ******** .. glossary:: add_test :term:`CMake` function used to add tests to the project, which will be run by :term:`CTest`. .. seealso:: https://cmake.org/cmake/help/latest/command/add_test.html CMake CMake is a compilation configuration platform that manages the build process in an operating system and in a compiler-independent manner. .. seealso:: https://cmake.org/overview/ CTest CTest is an executable that comes with :term:`CMake` which handles running the tests. .. seealso:: https://cmake.org/cmake/help/latest/manual/ctest.1.html GTest Google Test is a testing and mocking framework for C++. .. seealso:: http://google.github.io/googletest/ find_package :term:`CMake` function is used to provide locations of package dependencies to build a project. .. seealso:: https://cmake.org/cmake/help/latest/command/find_package.html fixture A :term:`Pytest` fixture provides a fixed setup and teardown for tests. .. seealso:: https://docs.pytest.org/en/latest/explanation/fixtures.html nanobind Nanobind is a fast, minimalistic C++ library designed to create Python bindings for C++ code. .. seealso:: https://nanobind.readthedocs.io/en/latest/index.html parametrizing tests Parameterized tests in :term:`Pytest` enable the execution of a single test function with multiple sets of input parameters, facilitating the evaluation of different test cases within a unified test structure. .. seealso:: https://docs.pytest.org/en/stable/how-to/parametrize.html regular expression A regular expression is a sequence of characters that defines a search pattern, typically used for pattern matching and manipulation within strings. .. seealso:: https://en.wikipedia.org/wiki/Regular_expression Pip Pip is a package-management system written for Python. .. seealso:: https://pip.pypa.io/en/stable/ Pytest Python testing framework. .. seealso:: https://docs.pytest.org/ python-cmake-pytest-cmake-702cb04/doc/index.rst000066400000000000000000000005501512605752200214530ustar00rootroot00000000000000.. _main: ############ Pytest CMake ############ Discover and run Python tests for :term:`Pytest` with :term:`CMake`. .. toctree:: :maxdepth: 1 introduction installing integration tutorial api_reference environment_variables release/index Source Code @ GitHub glossary python-cmake-pytest-cmake-702cb04/doc/installing.rst000066400000000000000000000030551512605752200225130ustar00rootroot00000000000000.. _installing: ************************ Installing Configuration ************************ .. highlight:: bash The :term:`CMake` configuration for the current :term:`Pytest` version can be easily installed using :term:`Pip`:: pip install pytest-cmake .. note:: :term:`Pytest` will be installed as a dependency if necessary. The configuration files should be located in the Python installation prefix:: /share/Pytest/cmake .. seealso:: :ref:`integration` .. _installing/source: Installing from source ====================== You can also install the configuration manually from the source for more control. First, obtain a copy of the source by either downloading the `zipball `_ or cloning the public repository:: git clone git@github.com:python-cmake/pytest-cmake.git Then build and install the package into your current Python environment:: pip install . .. note:: The project can not be installed in `editable mode `_ as package data won't be installed. .. _installing/source/doc: Building documentation from source ---------------------------------- Ensure you have installed the dependencies required for building the documentation:: pip install -r ./doc/requirements.txt Then, build the documentation with the command:: sphinx-build ./doc ./build/doc/html View the result in your browser at:: file:///path/to/sphinx-build/build/doc/html/index.html python-cmake-pytest-cmake-702cb04/doc/integration.rst000066400000000000000000000040571512605752200226750ustar00rootroot00000000000000.. _integration: ********************** Integrating with CMake ********************** .. highlight:: bash Once :ref:`installed `, the package integration within a :term:`CMake` project can be done using the :term:`find_package` function: .. code-block:: cmake find_package(Pytest) A specific range of versions can be targeted: .. code-block:: cmake # Request Pytest version 7.2.0. find_package(Pytest 7.2.0 EXACT REQUIRED) # Request Pytest between version 6.0.0 and 7.2.0 included. find_package(Pytest 6.0.0...7.2.0 REQUIRED) # Request any version of Pytest over 4.6.11. find_package(Pytest 4.6.11 REQUIRED) .. _integration/config: Finding Configuration ===================== When Python is used from its standard system location, :term:`CMake` should be able to discover the newly installed configuration automatically using its `Config Mode Search Procedure `_. .. warning:: The `CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH `_ option should not be set to False. When using a Python virtual environment, installing Python in a non-standard location, or installing ``pytest-cmake`` in the `Python user directory `_, specify the ``Pytest_ROOT`` path via the CLI:: cmake -S . -B ./build -D "Pytest_ROOT=$(python -m pytest_cmake --cmake-dir)" .. _integration/config/example: Building and testing example project ------------------------------------ An example project has been made available to test the configuration. Ensure that :term:`nanobind` is available, and install :term:`Pytest` with its :term:`CMake` configuration as described in the :ref:`previous section `. Then build the example:: cmake -S ./example -B ./build -D "nanobind_ROOT=$(python -m nanobind --cmake-dir)" cmake --build ./build Finally, run the tests as follows:: ctest --test-dir ./build -VV python-cmake-pytest-cmake-702cb04/doc/introduction.rst000066400000000000000000000027151512605752200230720ustar00rootroot00000000000000.. _introduction: ************ Introduction ************ This project provides convenient ways to use :term:`Pytest` within a :term:`CMake` project. The package can be discovered from a specific range of versions on Linux, macOS or Windows using the `find_package `_ function: .. code-block:: cmake find_package(Pytest 8.2.1 REQUIRED) A :func:`pytest_discover_tests` function is provided to simplify automatic testing for C++ projects with Python bindings. It can create :term:`CTest` tests for each Python test collected within a correct environment: .. code-block:: cmake pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ TRIM_FROM_NAME "^test_" DEPENDS MyLibrary ) Running the tests will display the status for each test collected as follows: .. code-block:: console 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 .. seealso:: :ref:`tutorial` python-cmake-pytest-cmake-702cb04/doc/release/000077500000000000000000000000001512605752200212325ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/doc/release/index.rst000066400000000000000000000004461512605752200230770ustar00rootroot00000000000000.. _release: *************************** Release and migration notes *************************** Find out what has changed between versions and see important migration notes to be aware of when switching to a new version. .. toctree:: :maxdepth: 1 release_notes migration_notes python-cmake-pytest-cmake-702cb04/doc/release/migration_notes.rst000066400000000000000000000005701512605752200251670ustar00rootroot00000000000000.. _release/migration: *************** Migration notes *************** This section will show more detailed information when relevant for switching to a new version, such as when upgrading involves backwards incompatibilities. .. _release/migration/1.0.0: Migrate to 1.0.0 ================ Dropped support for Python 2.x. The minimum supported version is now Python 3.7. python-cmake-pytest-cmake-702cb04/doc/release/release_notes.rst000066400000000000000000000223101512605752200246120ustar00rootroot00000000000000.. _release/release_notes: ************* Release Notes ************* .. release:: 1.3.0 :date: 2026-01-02 .. change:: changed Updated :term:`CMake` packaging by simplifying `PytestConfigVersion.cmake` so that version compatibility is no longer fixed at build time. Version discovery and validation are handled dynamically by `FindPytest.cmake`, with `PytestConfig.cmake` serving only as a thin entry point for :term:`CMake` package discovery. Wheel distribution is fully supported and recommended. Thanks :github_user:`dimbleby`! .. release:: 1.2.0 :date: 2025-12-08 .. change:: new Added compatibility with CMake 4.2 and Pytest v9. .. release:: 1.1.0 :date: 2025-08-14 .. change:: new Added ``pytest-cmake`` CLI with ``--cmake-dir`` to print the :term:`CMake` config path, simplifying integration with virtualenvs, non-standard installs, or `--user `_ installs. .. change:: changed Removed documentation for integrating the :term:`CMake` module directly from the Git repository, as this unsustainable method was already discouraged. .. release:: 1.0.0 :date: 2025-08-13 .. change:: changed Dropped support for Python 2.x. The minimum supported version is now Python 3.7. .. change:: new Added compatibility with CMake 4.1. .. change:: new Added ``TEST_PATHS`` option to the :func:`pytest_discover_tests` function, allowing users to limit test discovery and execution to specific files or directories. If not specified, ``TEST_PATHS`` defaults to the ``testpaths`` setting in :file:`pytest.ini`, or to the current directory if ``testpaths`` is not set. This matches :term:`Pytest`т€™s native behavior and preserves full backward compatibility. .. seealso:: `'testpaths' configuration option `_ .. change:: fixed Updated discovery error detection to recognize both block-form and single-line messages from :term:`Pytest`. .. release:: 0.13.0 :date: 2025-02-16 .. change:: changed Added ``DISCOVERY_EXTRA_ARGS`` option to the :func:`pytest_discover_tests` function, allowing custom arguments to be passed to the :term:`Pytest` command during test collection. Thanks :github_user:`AmeyaVS`! .. release:: 0.12.0 :date: 2025-02-09 .. change:: changed Added ``EXTRA_ARGS`` option to the :func:`pytest_discover_tests` function, allowing custom arguments to be passed to the :term:`Pytest` command when executing each test. Thanks :github_user:`AmeyaVS`! .. release:: 0.11.4 :date: 2025-01-29 .. change:: fixed Updated scripts to prevent uninitialized variable errors when using `-Werror=dev `_ and `--warn-uninitialized `_ options. Thanks :github_user:`corrodedHash`! .. release:: 0.11.3 :date: 2025-01-19 .. change:: changed Updated the :ref:`api_reference` section to include details on how ``DEPENDS`` can be used to ensure the target rebuilds whenever the Python files containing :term:`Pytest` tests are modified. Thanks :github_user:`AmeyaVSingh`! .. release:: 0.11.2 :date: 2025-01-18 .. change:: fixed Updated the :func:`pytest_discover_tests` function to support special characters in test names and identifiers. Thanks :github_user:`corrodedHash`! .. release:: 0.11.1 :date: 2024-10-27 .. change:: changed Updated the :func:`pytest_discover_tests` function to avoid rediscovering tests with every build. Thanks :github_user:`mhx`! .. release:: 0.11.0 :date: 2024-10-15 .. change:: new Added ``PROPERTIES`` option to the :func:`pytest_discover_tests` function, providing custom `test properties `_ for all generated tests. .. release:: 0.10.0 :date: 2024-10-11 .. change:: new Added ``INCLUDE_FILE_PATH`` option to the :func:`pytest_discover_tests` function, allowing the file path to be included in the test identifier. .. change:: new Added ``TRIM_FROM_FULL_NAME`` option to the :func:`pytest_discover_tests` function, enabling parts of the full test name to be trimmed. .. change:: fixed Fixed the ``BUNDLE_TESTS`` option to the :func:`pytest_discover_tests` function which was poorly implemented. .. change:: changed Replace Boost.Python with nanobind for the example module. .. seealso:: https://nanobind.readthedocs.io/en/latest/ .. release:: 0.9.0 :date: 2024-10-08 .. change:: new Added ``STRIP_PARAM_BRACKETS`` option to the :func:`pytest_discover_tests` function to strip square brackets used for :term:`parametrizing tests`. .. release:: 0.8.4 :date: 2024-10-06 .. change:: fixed Corrected the CMake version upper bound from 3.30 to 3.31. .. change:: changed Added documentation for deployment. .. change:: changed Added link to Github Project in documentation. .. release:: 0.8.3 :date: 2024-08-16 .. change:: fixed Fixed the :func:`pytest_discover_tests` function by serializing the `ENVIRONMENT` entries before transferring them to the intermediate script. .. release:: 0.8.2 :date: 2024-08-09 .. change:: new Added compatibility with CMake 3.30. .. release:: 0.8.1 :date: 2024-08-08 .. change:: fixed Ensure that the 'PYTEST_EXECUTABLE' variable is correctly serialized when the tests are created to handle cases where the path might contain spaces or special characters. .. release:: 0.8.0 :date: 2024-08-01 .. change:: changed Improved the :func:`pytest_discover_tests` function to use an intermediate CMake script during :term:`CTest` runs. This update enables partial builds that exclude the corresponding CMake target to be executed and tested. .. release:: 0.7.0 :date: 2024-05-31 .. change:: fixed Updated CMake script to enable the trimming of class and method names on discovered tests. .. change:: changed Updated documentation. .. release:: 0.6.0 :date: 2024-05-11 .. change:: changed Updated CMake script to ensure that environment variables are preserving the Windows-style path syntax when running the tests. .. seealso:: https://github.com/python-cmake/pytest-cmake/issues/22 .. change:: changed Improve tests. .. release:: 0.5.2 :date: 2024-05-06 .. change:: fixed Updated test collection logic to ensure that the 'rootdir' is a real path. Previously, running the tests from a symlinked directory could result in errors when discovering 'conftests' configurations. .. seealso:: https://github.com/pytest-dev/pytest/issues/12291 .. release:: 0.5.1 :date: 2024-03-17 .. change:: fixed Fixed CI Deployment script. .. release:: 0.5.0 :date: 2024-03-17 .. change:: changed Updated CMake script now interrupts the build if the Python test collection fails. .. release:: 0.4.1 :date: 2024-03-17 .. change:: fixed As of Hatching v1.22, dynamic dependencies during build time must be imported lazily. Therefore, the backend script has been updated to import 'pytest' only when the build hook is called. .. seealso:: `BuildHookInterface.dependencies `_ .. release:: 0.4.0 :date: 2024-03-03 .. change:: fixed Fixed CMake script to ensure that library and Python path list environment variables are represented as strings before serializing the CTest commands. .. change:: changed Updated Github CI script to run all tests once a week. .. change:: new Added compatibility with Pytest v8 and CMake 3.29. .. release:: 0.3.0 :date: 2023-07-18 .. change:: new Added ``ENVIRONMENT`` option to the :func:`pytest_discover_tests` function to provide custom environment variables during the tests. .. seealso:: :ref:`tutorial/function` .. release:: 0.2.1 :date: 2023-01-20 .. change:: fixed Updated configuration to include custom backend script in Python distribution. .. change:: fixed Fixed incorrect CMake functions in documentation. .. release:: 0.2.0 :date: 2023-01-20 .. change:: changed Added custom build backend to ensure compatibility with Python 2.7. .. release:: 0.1.0 :date: 2022-12-13 .. change:: new Initial release with the :term:`Pip` package manager. python-cmake-pytest-cmake-702cb04/doc/requirements.txt000066400000000000000000000000461512605752200230760ustar00rootroot00000000000000Sphinx==7.3.7 sphinx-rtd-theme==2.0.0 python-cmake-pytest-cmake-702cb04/doc/tutorial.rst000066400000000000000000000154041512605752200222130ustar00rootroot00000000000000.. _tutorial: ******** Tutorial ******** Once :ref:`integrated into your project `, the ``Pytest::Pytest`` target and the :func:`pytest_discover_tests` function are available for using. .. _tutorial/target: Using the target ================ Let's consider a project that wraps C++ logic with Python bindings. We need to add a :file:`CMakeLists.txt` configuration file to include Python tests within the same directory. The :term:`Pytest` command can easily be implemented using the :term:`add_test` function: .. code-block:: cmake add_test( NAME PythonTest COMMAND Pytest::Pytest ${CMAKE_CURRENT_SOURCE_DIR} ) For the tests to run, the :envvar:`PYTHONPATH` environment variable must be updated to locate the built package library. We can use a generator expression to resolve the path of the dependent target directory dynamically: .. code-block:: cmake set_tests_properties( TEST PythonTest PROPERTY ENVIRONMENT PYTHONPATH=$:$ENV{PYTHONPATH} ) The shared library might also be required during runtime execution, so its location should be provided: .. code-block:: cmake set_tests_properties( TEST PythonTest APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH} ) .. warning:: The environment variable used to locate shared libraries depends on the platform. :envvar:`LD_LIBRARY_PATH` is used on Linux, :envvar:`DYLD_LIBRARY_PATH` on macOS, and :envvar:`PATH` on Windows. After building the project, the tests can then be executed using :term:`CTest`. If all tests are successful, the output will look as follows: .. code-block:: console Start 1: PythonTest 1/1 Test #1: PythonTest ....................... Passed 0.55 sec However, if only one test is unsuccessful, the entire test suite will be marked as failed. .. code-block:: console Start 1: PythonTest 1/1 Test #1: PythonTest .......................***Failed 0.47 sec .. _tutorial/function: Using the function ================== A :func:`pytest_discover_tests` function is provided to create :term:`CMake` tests for each Python test collected. Therefore, the configuration added in the previous section could be replaced by the following: .. code-block:: cmake pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ DEPENDS MyLibrary ) This will create a new **PythonTest** target, dependent on the **MyLibrary** target. The expected environment can be defined simply with the ``LIBRARY_PATH_PREPEND`` and ``PYTHON_PATH_PREPEND`` options, which both accept multiple values. The environment variable used to locate shared libraries will be automatically chosen according to the platform. A list of dependent targets can be defined with the ``DEPENDS`` option, which accepts multiple values. After building the project, running :term:`CTest` will display the tests as follows: .. code-block:: console Start 1: PythonTest.test_greet_world 1/4 Test #1: PythonTest.test_greet_world ........... Passed 0.47 sec Start 2: PythonTest.test_greet_john 2/4 Test #2: PythonTest.test_greet_john ............ Passed 0.47 sec Start 3: PythonTest.test_greet_julia 3/4 Test #3: PythonTest.test_greet_julia ........... Passed 0.47 sec Start 4: PythonTest.test_greet_michael 4/4 Test #4: PythonTest.test_greet_michael ......... Passed 0.54 sec A fully identified test collected by :term:`Pytest` might look like this: .. code-block:: console tests/test_module.py::TestMyClass::test_example By default, only the class and function name of each :term:`Pytest` test collected are used to create the :term:`CMake` tests. You can use the ``INCLUDE_FILE_PATH`` option to include the file path within the name: .. code-block:: cmake :emphasize-lines: 7 pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ INCLUDE_FILE_PATH DEPENDS MyLibrary ) Pytest usually requires the test class and function to start with a `specific prefix `_, which can be trimmed using the ``TRIM_FROM_NAME`` or ``TRIM_FROM_FULL_NAME`` options. The value can use a :term:`regular expression` to match the part of the test name that should be trimmed. The ``TRIM_FROM_FULL_NAME`` option can be used to trim parts of the entire name, while the ``TRIM_FROM_NAME`` option will be applied to the class, method and function name of each :term:`Pytest` test collected for convenience. .. code-block:: cmake :emphasize-lines: 7 pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ TRIM_FROM_NAME "^(Test|test_)" INCLUDE_FILE_PATH DEPENDS MyLibrary ) After rebuilding the project, running :term:`CTest` will display the tests as follows: .. code-block:: console 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.subfolder.greet_michael 4/4 Test #4: PythonTest.subfolder.greet_michael ... Passed 0.54 sec You can also define custom environment variables and test properties using the ``ENVIRONMENT`` and ``PROPERTIES`` options, respectively. It is also possible to regroup all tests under one :term:`CTest` test, as was the case when :ref:`using the target `. This can be useful during development to ensure that the tests run faster, especially if you use :term:`fixtures ` with a broader scope. This can be done by setting the ``BUNDLE_TESTS`` option to True: .. code-block:: cmake :emphasize-lines: 8 pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ PYTHON_PATH_PREPEND $ DEPENDS MyLibrary BUNDLE_TESTS True ) After rebuilding the project once again, running :term:`CTest` will display the tests as follows: .. code-block:: console Start 1: PythonTest 1/1 Test #1: PythonTest ....................... Passed 0.51 sec .. note:: The :envvar:`BUNDLE_PYTHON_TESTS` environment variable can also set this option dynamically. python-cmake-pytest-cmake-702cb04/example/000077500000000000000000000000001512605752200205005ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/CMakeLists.txt000066400000000000000000000007011512605752200232360ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(Example) if (NOT "${CMAKE_CXX_STANDARD}") set(CMAKE_CXX_STANDARD 17 CACHE STRING "Default C++ standard") endif() if (WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) endif() find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED) find_package(nanobind CONFIG REQUIRED) find_package(Pytest 4.6.11 REQUIRED) enable_testing() add_subdirectory(src) add_subdirectory(test) python-cmake-pytest-cmake-702cb04/example/src/000077500000000000000000000000001512605752200212675ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/src/CMakeLists.txt000066400000000000000000000000571512605752200240310ustar00rootroot00000000000000add_subdirectory(foo) add_subdirectory(python) python-cmake-pytest-cmake-702cb04/example/src/foo/000077500000000000000000000000001512605752200220525ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/src/foo/CMakeLists.txt000066400000000000000000000002041512605752200246060ustar00rootroot00000000000000add_library(foo SHARED foo.cpp) target_include_directories(foo PUBLIC $ ) python-cmake-pytest-cmake-702cb04/example/src/foo/foo.cpp000066400000000000000000000016651512605752200233510ustar00rootroot00000000000000#include "./foo.h" #include #include #include #include #include #include Foo::Foo() { const char* settings = std::getenv("FOO_SETTINGS_FILE"); if (settings == nullptr) { throw std::runtime_error("Environment variable FOO_SETTINGS_FILE is not set."); } std::ifstream file(settings); if (!file.is_open()) { throw std::runtime_error("Unable to open Foo file."); } std::string line; while (std::getline(file, line)) { std::istringstream iss(line); std::string lang, greeting; if (std::getline(iss, lang, ':') && std::getline(iss, greeting)) { _map[lang] = greeting; } } file.close(); } std::string Foo::sayHello(std::string language) { if (_map.find(language) == _map.end()) { throw std::runtime_error("Language not found in Foo file."); } return _map[language]; } python-cmake-pytest-cmake-702cb04/example/src/foo/foo.h000066400000000000000000000004441512605752200230100ustar00rootroot00000000000000#ifndef EXAMPLE_FOO_H #define EXAMPLE_FOO_H #include #include class Foo { public: Foo(); virtual ~Foo() = default; std::string sayHello(std::string language); private: std::unordered_map _map; }; #endif // EXAMPLE_FOO_H python-cmake-pytest-cmake-702cb04/example/src/python/000077500000000000000000000000001512605752200226105ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/src/python/CMakeLists.txt000066400000000000000000000013031512605752200253450ustar00rootroot00000000000000nanobind_add_module(pyFoo main.cpp) set_target_properties(pyFoo PROPERTIES PREFIX "" SUFFIX ".so" OUTPUT_NAME foo ) if(WIN32) set_target_properties(pyFoo PROPERTIES SUFFIX ".pyd") endif() target_link_libraries(pyFoo PUBLIC foo) if (WIN32) # As of Python v3.8 and newer, DLLs are no longer searched for in the # PATH environment variable on Windows. Therefore, it is necessary to # ensure that they are all located in the same directory. add_custom_command( TARGET pyFoo POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) endif() python-cmake-pytest-cmake-702cb04/example/src/python/main.cpp000066400000000000000000000007461512605752200242470ustar00rootroot00000000000000#include #include #include #include #include namespace nb = nanobind; std::string greet(const std::string& name = "world") { Foo foo; const char* value = std::getenv("DEFAULT_LANGUAGE"); if (value != nullptr) return foo.sayHello(value) + ", " + name; else return foo.sayHello("fr") + ", " + name; } NB_MODULE(foo, m) { m.def("greet", &greet, nb::arg("name") = "world"); } python-cmake-pytest-cmake-702cb04/example/test/000077500000000000000000000000001512605752200214575ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/test/CMakeLists.txt000066400000000000000000000022311512605752200242150ustar00rootroot00000000000000pytest_discover_tests( PythonTest LIBRARY_PATH_PREPEND $ $ PYTHON_PATH_PREPEND $ TRIM_FROM_NAME "^(Test|test_)" STRIP_PARAM_BRACKETS INCLUDE_FILE_PATH DEPENDS foo pyFoo ENVIRONMENT "DEFAULT_LANGUAGE=en" "FOO_SETTINGS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/resource/foo.txt" PROPERTIES TIMEOUT 120 ) if (WIN32) # Expand functions to copy dependent DLLs in the same folder after # building target to ensure that tests can run properly on Windows. macro(add_test NAME) add_custom_command( TARGET ${NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) _add_test(${NAME} ${ARGV}) endmacro() endif() add_executable(CppTest fooTest.cpp) target_link_libraries(CppTest foo) add_test(CppTest CppTest) set_tests_properties( CppTest PROPERTIES ENVIRONMENT "FOO_SETTINGS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/resource/foo.txt" ) python-cmake-pytest-cmake-702cb04/example/test/fooTest.cpp000066400000000000000000000001401512605752200236010ustar00rootroot00000000000000#include "foo.h" int main() { Foo foo; return foo.sayHello("en") == "hello" ? 0 : 1; } python-cmake-pytest-cmake-702cb04/example/test/resource/000077500000000000000000000000001512605752200233065ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/test/resource/foo.txt000066400000000000000000000000331512605752200246260ustar00rootroot00000000000000en:hello fr:bonjour es:holapython-cmake-pytest-cmake-702cb04/example/test/subfolder/000077500000000000000000000000001512605752200234445ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/example/test/subfolder/test_example2.py000066400000000000000000000006621512605752200265760ustar00rootroot00000000000000import foo import pytest def test_greet_michael(): """Greet Michael.""" assert foo.greet("Michael") == "hello, Michael" def test_greet_error(monkeypatch): """Impossible to greet when FOO settings is not found.""" monkeypatch.delenv("FOO_SETTINGS_FILE") with pytest.raises(RuntimeError) as error: foo.greet("Michael") assert "Environment variable FOO_SETTINGS_FILE is not set" in str(error.value)python-cmake-pytest-cmake-702cb04/example/test/test_example.py000066400000000000000000000016311512605752200245240ustar00rootroot00000000000000import pytest import foo def test_greet_world(): """Greet the world.""" assert foo.greet() == "hello, world" def test_greet_john(): """Greet John.""" assert foo.greet("John") == "hello, John" def test_greet_julia(): """Greet Julia.""" assert foo.greet("Julia") == "hello, Julia" @pytest.mark.parametrize("name", [ "Alan", "Stephen", "Ford[Perfect]", ]) def test_greet(name): """Greet various persons.""" assert foo.greet(name) == f"hello, {name}" class TestLanguage: """Bundle language tests.""" def test_greet_french(self, monkeypatch): """Greet Julia in French.""" monkeypatch.delenv("DEFAULT_LANGUAGE") assert foo.greet("Julia") == "bonjour, Julia" def test_greet_spanish(self, monkeypatch): """Greet Julia in Spanish.""" monkeypatch.setenv("DEFAULT_LANGUAGE", "es") assert foo.greet("Julia") == "hola, Julia" python-cmake-pytest-cmake-702cb04/pyproject.toml000066400000000000000000000037501512605752200217660ustar00rootroot00000000000000[build-system] requires = [ "hatchling >= 1.4", "cmake >= 3.20, < 4.3" ] build-backend = "hatchling.build" [project] name = "pytest-cmake" version = "1.3.0" description = "Provide CMake module for Pytest" readme = "README.md" requires-python = ">=3.7, <4" license = {file = "LICENSE"} keywords = ["cmake", "pytest", "development"] authors = [ {name = "Jeremy Retailleau", email = "jeremy.retailleau@gmail.com" } ] dependencies = [ "pytest >= 4, < 10", ] classifiers = [ "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", ] [project.scripts] pytest-cmake = "pytest_cmake.__main__:main" [project.urls] Documentation = "https://python-cmake.github.io/pytest-cmake" Repository = "https://github.com/python-cmake/pytest-cmake" Issues = "https://github.com/python-cmake/pytest-cmake/issues" Changelog = "https://python-cmake.github.io/pytest-cmake/release/release_notes.html" [tool.hatch.build.hooks.custom] require-runtime-dependencies = true path = "build_config.py" [tool.hatch.build.targets.wheel.shared-data] "build/PytestConfig.cmake" = "share/Pytest/cmake/PytestConfig.cmake" "build/PytestConfigVersion.cmake" = "share/Pytest/cmake/PytestConfigVersion.cmake" "cmake/FindPytest.cmake" = "share/Pytest/cmake/FindPytest.cmake" "cmake/PytestAddTests.cmake" = "share/Pytest/cmake/PytestAddTests.cmake" [tool.hatch.build.targets.wheel] packages = ["src/pytest_cmake"] only-include = ["src/pytest_cmake", "*.cmake"] [tool.hatch.build.targets.sdist] only-include = ["src/pytest_cmake", "cmake", "build_config.py"] python-cmake-pytest-cmake-702cb04/src/000077500000000000000000000000001512605752200176345ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/src/pytest_cmake/000077500000000000000000000000001512605752200223245ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/src/pytest_cmake/__init__.py000066400000000000000000000000001512605752200244230ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/src/pytest_cmake/__main__.py000066400000000000000000000012431512605752200244160ustar00rootroot00000000000000import argparse from pathlib import Path import sys import sysconfig def main(argv=None) -> int: parser = argparse.ArgumentParser( prog="pytest-cmake", description="Utility commands for pytest-cmake packaging.", ) parser.add_argument( "--cmake_dir", "--cmake-dir", action="store_true", help="Print the CMake config directory path and exit.", ) args = parser.parse_args(argv) if args.cmake_dir: data_root = Path(sysconfig.get_path("data")) print(data_root / "share" / "Pytest" / "cmake") return 0 parser.print_help() return 0 if __name__ == "__main__": sys.exit(main()) python-cmake-pytest-cmake-702cb04/test/000077500000000000000000000000001512605752200200245ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/00-version-fails/000077500000000000000000000000001512605752200230225ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/00-version-fails/CMakeLists.txt000066400000000000000000000001441512605752200255610ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestVersionFails) find_package(Pytest 99.0 REQUIRED) python-cmake-pytest-cmake-702cb04/test/01-modify-name/000077500000000000000000000000001512605752200224475ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/01-modify-name/CMakeLists.txt000066400000000000000000000163331512605752200252150ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestModifyName) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests(TestModifyName.Simple) set(EXPECTED "TestModifyName.Simple.test_inventory_keys" "TestModifyName.Simple.test_fruit_quantity[Fruit[banana]=150]" "TestModifyName.Simple.test_fruit_quantity[Fruit[apple]=100]" "TestModifyName.Simple.test_inventory_values" "TestModifyName.Simple.test_fruit_quantity[Fruit[orange]=200]" "TestModifyName.Simple.TestStringMethods.test_upper" "TestModifyName.Simple.TestStringMethods.test_lower" "TestModifyName.Simple.TestStringMethods.test_capitalize" "TestModifyName.Simple.TestStringMethods.test_split" "TestModifyName.Simple.test_addition" "TestModifyName.Simple.test_subtraction" "TestModifyName.Simple.test_addition_with_params[5-5-10]" "TestModifyName.Simple.test_addition_with_params[10-5-15]" "TestModifyName.Simple.test_addition_with_params[0-0-0]" "TestModifyName.Simple.test_byte_char_conversion[\\x17]" ) add_test(NAME TestModifyName.Validate.Simple COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.Simple" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests(TestModifyName.Bundled BUNDLE_TESTS) add_test(NAME TestModifyName.Validate.Bundled COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.Bundled" -D "EXPECTED=TestModifyName.Bundled" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestModifyName.TrimFromName TRIM_FROM_NAME "^(Test|test_)" ) set(EXPECTED "TestModifyName.TrimFromName.inventory_keys" "TestModifyName.TrimFromName.inventory_values" "TestModifyName.TrimFromName.fruit_quantity[Fruit[banana]=150]" "TestModifyName.TrimFromName.fruit_quantity[Fruit[apple]=100]" "TestModifyName.TrimFromName.fruit_quantity[Fruit[orange]=200]" "TestModifyName.TrimFromName.StringMethods.upper" "TestModifyName.TrimFromName.StringMethods.lower" "TestModifyName.TrimFromName.StringMethods.capitalize" "TestModifyName.TrimFromName.StringMethods.split" "TestModifyName.TrimFromName.addition" "TestModifyName.TrimFromName.subtraction" "TestModifyName.TrimFromName.addition_with_params[5-5-10]" "TestModifyName.TrimFromName.addition_with_params[10-5-15]" "TestModifyName.TrimFromName.addition_with_params[0-0-0]" "TestModifyName.TrimFromName.byte_char_conversion[\\x17]" ) add_test(NAME TestModifyName.Validate.TrimFromName COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.TrimFromName" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestModifyName.StripParamBrackets STRIP_PARAM_BRACKETS ) set(EXPECTED "TestModifyName.StripParamBrackets.test_inventory_keys" "TestModifyName.StripParamBrackets.test_inventory_values" "TestModifyName.StripParamBrackets.test_fruit_quantity.Fruit[banana]=150" "TestModifyName.StripParamBrackets.test_fruit_quantity.Fruit[apple]=100" "TestModifyName.StripParamBrackets.test_fruit_quantity.Fruit[orange]=200" "TestModifyName.StripParamBrackets.TestStringMethods.test_upper" "TestModifyName.StripParamBrackets.TestStringMethods.test_lower" "TestModifyName.StripParamBrackets.TestStringMethods.test_capitalize" "TestModifyName.StripParamBrackets.TestStringMethods.test_split" "TestModifyName.StripParamBrackets.test_addition" "TestModifyName.StripParamBrackets.test_subtraction" "TestModifyName.StripParamBrackets.test_addition_with_params.5-5-10" "TestModifyName.StripParamBrackets.test_addition_with_params.10-5-15" "TestModifyName.StripParamBrackets.test_addition_with_params.0-0-0" "TestModifyName.StripParamBrackets.test_byte_char_conversion.\\x17" ) add_test(NAME TestModifyName.Validate.StripParamBrackets COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.StripParamBrackets" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestModifyName.IncludeFilePath INCLUDE_FILE_PATH ) set(EXPECTED "TestModifyName.IncludeFilePath.data.test_sample_data.test_inventory_keys" "TestModifyName.IncludeFilePath.data.test_sample_data.test_inventory_values" "TestModifyName.IncludeFilePath.data.test_sample_data.test_fruit_quantity[Fruit[banana]=150]" "TestModifyName.IncludeFilePath.data.test_sample_data.test_fruit_quantity[Fruit[apple]=100]" "TestModifyName.IncludeFilePath.data.test_sample_data.test_fruit_quantity[Fruit[orange]=200]" "TestModifyName.IncludeFilePath.strings.test_string_methods.TestStringMethods.test_upper" "TestModifyName.IncludeFilePath.strings.test_string_methods.TestStringMethods.test_lower" "TestModifyName.IncludeFilePath.strings.test_string_methods.TestStringMethods.test_capitalize" "TestModifyName.IncludeFilePath.strings.test_string_methods.TestStringMethods.test_split" "TestModifyName.IncludeFilePath.test_math_operations.test_addition" "TestModifyName.IncludeFilePath.test_math_operations.test_subtraction" "TestModifyName.IncludeFilePath.test_math_operations.test_addition_with_params[5-5-10]" "TestModifyName.IncludeFilePath.test_math_operations.test_addition_with_params[10-5-15]" "TestModifyName.IncludeFilePath.test_math_operations.test_addition_with_params[0-0-0]" "TestModifyName.IncludeFilePath.test_math_operations.test_byte_char_conversion[\\x17]" ) add_test(NAME TestModifyName.Validate.IncludeFilePath COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.IncludeFilePath" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestModifyName.TrimFromFullName TRIM_FROM_FULL_NAME "(math_|fruit_|test_)" INCLUDE_FILE_PATH ) set(EXPECTED "TestModifyName.TrimFromFullName.data.sample_data.inventory_keys" "TestModifyName.TrimFromFullName.data.sample_data.inventory_values" "TestModifyName.TrimFromFullName.data.sample_data.quantity[Fruit[banana]=150]" "TestModifyName.TrimFromFullName.data.sample_data.quantity[Fruit[apple]=100]" "TestModifyName.TrimFromFullName.data.sample_data.quantity[Fruit[orange]=200]" "TestModifyName.TrimFromFullName.strings.string_methods.TestStringMethods.upper" "TestModifyName.TrimFromFullName.strings.string_methods.TestStringMethods.lower" "TestModifyName.TrimFromFullName.strings.string_methods.TestStringMethods.capitalize" "TestModifyName.TrimFromFullName.strings.string_methods.TestStringMethods.split" "TestModifyName.TrimFromFullName.operations.addition" "TestModifyName.TrimFromFullName.operations.subtraction" "TestModifyName.TrimFromFullName.operations.addition_with_params[5-5-10]" "TestModifyName.TrimFromFullName.operations.addition_with_params[10-5-15]" "TestModifyName.TrimFromFullName.operations.addition_with_params[0-0-0]" "TestModifyName.TrimFromFullName.operations.byte_char_conversion[\\x17]" ) add_test(NAME TestModifyName.Validate.TrimFromFullName COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestModifyName.TrimFromFullName" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) python-cmake-pytest-cmake-702cb04/test/01-modify-name/data/000077500000000000000000000000001512605752200233605ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/01-modify-name/data/conftest.py000066400000000000000000000003151512605752200255560ustar00rootroot00000000000000import pytest @pytest.fixture def sample_data(): return { "banana": {"quantity_in_stock": 150}, "apple": {"quantity_in_stock": 100}, "orange": {"quantity_in_stock": 200} } python-cmake-pytest-cmake-702cb04/test/01-modify-name/data/test_sample_data.py000066400000000000000000000012151512605752200272420ustar00rootroot00000000000000import pytest def test_inventory_keys(sample_data): for fruit in sample_data: assert "quantity_in_stock" in sample_data[fruit] def test_inventory_values(sample_data): for fruit, data in sample_data.items(): assert isinstance(data["quantity_in_stock"], int) assert data["quantity_in_stock"] > 0 @pytest.mark.parametrize("fruit, expected_quantity", [ ("banana", 150), ("apple", 100), ("orange", 200), ], ids=["Fruit[banana]=150", "Fruit[apple]=100", "Fruit[orange]=200"]) def test_fruit_quantity(sample_data, fruit, expected_quantity): assert sample_data[fruit]["quantity_in_stock"] == expected_quantity python-cmake-pytest-cmake-702cb04/test/01-modify-name/strings/000077500000000000000000000000001512605752200241405ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/01-modify-name/strings/test_string_methods.py000066400000000000000000000006531512605752200306060ustar00rootroot00000000000000import pytest class TestStringMethods: def test_upper(self): assert "example".upper() == "EXAMPLE" def test_lower(self): assert "EXAMPLE".lower() == "example" def test_capitalize(self): assert "hello".capitalize() == "Hello" def test_split(self): s = "hello world" assert s.split() == ["hello", "world"] with pytest.raises(TypeError): s.split(2) python-cmake-pytest-cmake-702cb04/test/01-modify-name/test_math_operations.py000066400000000000000000000006141512605752200272550ustar00rootroot00000000000000import pytest def test_addition(): assert 2 + 3 == 5 def test_subtraction(): assert 5 - 2 == 3 @pytest.mark.parametrize("a, b, expected", [ (5, 5, 10), (10, 5, 15), (0, 0, 0), ]) def test_addition_with_params(a, b, expected): assert a + b == expected @pytest.mark.parametrize("input", [ "\x17", ]) def test_byte_char_conversion(input): assert ord(input) < 128 python-cmake-pytest-cmake-702cb04/test/02-library-path/000077500000000000000000000000001512605752200226415ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/02-library-path/CMakeLists.txt000066400000000000000000000013251512605752200254020ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestLibraryPath) find_package(Pytest REQUIRED) enable_testing() if(WIN32) set(EXPECTED "\\path") else() set(EXPECTED "/path") endif() configure_file(test_path.py "test1/test_path.py" @ONLY) pytest_discover_tests( TestLibraryPath.AddOne LIBRARY_PATH_PREPEND "/path" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test1" ) if(WIN32) set(EXPECTED "\\path1;\\path2;\\path3") else() set(EXPECTED "/path1:/path2:/path3") endif() configure_file(test_path.py "test2/test_path.py" @ONLY) pytest_discover_tests( TestLibraryPath.AddSeveral LIBRARY_PATH_PREPEND "/path1" "/path2" "/path3" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test2" ) python-cmake-pytest-cmake-702cb04/test/02-library-path/test_path.py000066400000000000000000000010101512605752200251760ustar00rootroot00000000000000import os import platform PREPENDED_PATH = "@EXPECTED@" def test_path(): """Ensure that the path has been prepended as expected.""" env_vars = { "Linux": "LD_LIBRARY_PATH", "Darwin": "DYLD_LIBRARY_PATH", } env_var = env_vars.get(platform.system(), "PATH") current_path = os.environ.get(env_var, "") assert current_path == PREPENDED_PATH or current_path.startswith(PREPENDED_PATH + os.pathsep), \ f"{env_var} does not start with {PREPENDED_PATH}, found: {current_path}" python-cmake-pytest-cmake-702cb04/test/03-python-path/000077500000000000000000000000001512605752200225175ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/03-python-path/CMakeLists.txt000066400000000000000000000013201512605752200252530ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestPythonPath) find_package(Pytest REQUIRED) enable_testing() if(WIN32) set(EXPECTED "\\path") else() set(EXPECTED "/path") endif() configure_file(test_path.py "test1/test_path.py" @ONLY) pytest_discover_tests( TestPythonPath.AddOne PYTHON_PATH_PREPEND "/path" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test1" ) if(WIN32) set(EXPECTED "\\path1;\\path2;\\path3") else() set(EXPECTED "/path1:/path2:/path3") endif() configure_file(test_path.py "test2/test_path.py" @ONLY) pytest_discover_tests( TestPythonPath.AddSeveral PYTHON_PATH_PREPEND "/path1" "/path2" "/path3" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test2" ) python-cmake-pytest-cmake-702cb04/test/03-python-path/test_path.py000066400000000000000000000005461512605752200250710ustar00rootroot00000000000000import os PREPENDED_PATH = "@EXPECTED@" def test_path(): """Ensure that the path has been prepended as expected.""" current_path = os.environ.get("PYTHONPATH", "") assert current_path == PREPENDED_PATH or current_path.startswith(PREPENDED_PATH + os.pathsep), \ f"PYTHONPATH does not start with {PREPENDED_PATH}, found: {current_path}" python-cmake-pytest-cmake-702cb04/test/04-environment/000077500000000000000000000000001512605752200226115ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/04-environment/CMakeLists.txt000066400000000000000000000005701512605752200253530ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestEnvironment) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests( TestEnvironment ENVIRONMENT "KEY1=VALUE1" "KEY2=VALUE2" "KEY3=PATH1:PATH2:PATH3" "KEY4=PATH1\;PATH2\;PATH3" "KEY5=C:\\Path\\To\\Dir1\;C:\\Path\\To\\Dir2" "K3Y4=SPECIAL$VALUE!@#%^&*" ) python-cmake-pytest-cmake-702cb04/test/04-environment/test_env.py000066400000000000000000000012431512605752200250120ustar00rootroot00000000000000import os import platform def test_env(): """Ensure that the environment variables have been set.""" assert os.environ.get("KEY1", "") == "VALUE1" assert os.environ.get("KEY2", "") == "VALUE2" assert os.environ.get("KEY3", "") == "PATH1:PATH2:PATH3" if platform.system() == "Windows": assert os.environ.get("KEY4", "") == "PATH1;PATH2;PATH3" assert os.environ.get("KEY5", "") == r"C:\Path\To\Dir1;C:\Path\To\Dir2" else: assert os.environ.get("KEY4", "") == "PATH1\;PATH2\;PATH3" assert os.environ.get("KEY5", "") == r"C:\Path\To\Dir1\;C:\Path\To\Dir2" assert os.environ.get("K3Y4", "") == "SPECIAL$VALUE!@#%^&*" python-cmake-pytest-cmake-702cb04/test/05-properties/000077500000000000000000000000001512605752200224425ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/05-properties/CMakeLists.txt000066400000000000000000000027101512605752200252020ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestProperties) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests( TestProperties.Timeout PROPERTIES TIMEOUT 120 ) add_test(NAME TestProperties.Validate.Timeout COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestProperties.Timeout" -D "TEST_PROPERTY=TIMEOUT" -D "EXPECTED_VALUE=120.0" -P ${CMAKE_CURRENT_LIST_DIR}/check_test_property.cmake ) pytest_discover_tests( TestProperties.Labels PROPERTIES LABELS "foo\;bar" ) add_test(NAME TestProperties.Validate.Labels COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestProperties.Labels" -D "TEST_PROPERTY=LABELS" -D "EXPECTED_VALUE=[ \"bar\", \"foo\" ]" -P ${CMAKE_CURRENT_LIST_DIR}/check_test_property.cmake ) pytest_discover_tests( TestProperties.Disabled PROPERTIES DISABLED ON ) add_test(NAME TestProperties.Validate.Disabled COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestProperties.Disabled" -D "TEST_PROPERTY=DISABLED" -D "EXPECTED_VALUE=ON" -P ${CMAKE_CURRENT_LIST_DIR}/check_test_property.cmake ) pytest_discover_tests( TestProperties.SkipReturnCode PROPERTIES SKIP_RETURN_CODE 77 ) add_test(NAME TestProperties.Validate.SkipReturnCode COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestProperties.SkipReturnCode" -D "TEST_PROPERTY=SKIP_RETURN_CODE" -D "EXPECTED_VALUE=77" -P ${CMAKE_CURRENT_LIST_DIR}/check_test_property.cmake ) python-cmake-pytest-cmake-702cb04/test/05-properties/check_test_property.cmake000066400000000000000000000036261512605752200275330ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) execute_process( COMMAND ${CMAKE_CTEST_COMMAND} --show-only=json-v1 -R "${TEST_PREFIX}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE test_output OUTPUT_STRIP_TRAILING_WHITESPACE ) # Trailing slashes in Windows environment paths produce '\;', leading to JSON # parsing issues. Replace '\;' with ';' to resolve. string(REPLACE [[\;]] [[;]] test_output "${test_output}") string(JSON num_tests LENGTH ${test_output} tests) if (num_tests EQUAL 0) message(FATAL_ERROR "'${TEST_PREFIX}': No tests discovered.") endif() string(JSON tests_array GET ${test_output} tests) math(EXPR last_test_index "${num_tests}-1") foreach (i RANGE 0 ${last_test_index}) string(JSON test_name GET ${tests_array} ${i} name) string(JSON num_properties LENGTH ${tests_array} ${i} properties) if (num_properties EQUAL 0) message(FATAL_ERROR "Test '${test_name}' does not have properties.") endif() string(JSON properties GET ${tests_array} ${i} properties) math(EXPR last_property_index "${num_properties}-1") set(property_found 0) foreach (j RANGE 0 ${last_property_index}) string(JSON property_name GET ${properties} ${j} name) string(JSON property_value GET ${properties} ${j} value) message("${property_name} = ${property_value}") if (property_name STREQUAL "${TEST_PROPERTY}") set(property_found 1) if (NOT "${property_value}" STREQUAL "${EXPECTED_VALUE}") message(FATAL_ERROR "Test '${test_name}' does not have ${TEST_PROPERTY} set to ${EXPECTED_VALUE}.\n" "Found: ${property_value}" ) endif() endif() endforeach() if(NOT property_found) message(FATAL_ERROR "Test '${test_name}' does not have ${TEST_PROPERTY} property." ) endif() endforeach()python-cmake-pytest-cmake-702cb04/test/05-properties/test_property.py000066400000000000000000000000531512605752200257350ustar00rootroot00000000000000def test_addition(): assert 1 + 1 == 2 python-cmake-pytest-cmake-702cb04/test/06-extra-args/000077500000000000000000000000001512605752200223245ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/06-extra-args/CMakeLists.txt000066400000000000000000000012041512605752200250610ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestExtraArgs) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests( TestExtraArgs EXTRA_ARGS "--capture=no" "--cmdopt=demo" ) pytest_discover_tests( TestDiscoveryExtraArgs.IgnoreCustomArgs EXTRA_ARGS "--capture=no" DISCOVERY_EXTRA_ARGS "--ignore=custom_args" ) pytest_discover_tests( TestDiscoveryExtraArgs.OnlyCustomArgs EXTRA_ARGS "--cmdopt=demo" DISCOVERY_EXTRA_ARGS "-k=custom" ) pytest_discover_tests( TestDiscoveryExtraArgs.OnlyCustomArgsBundled EXTRA_ARGS "--cmdopt=demo" DISCOVERY_EXTRA_ARGS "-k=custom" BUNDLE_TESTS ) python-cmake-pytest-cmake-702cb04/test/06-extra-args/conftest.py000066400000000000000000000001641512605752200245240ustar00rootroot00000000000000def pytest_addoption(parser): parser.addoption( "--cmdopt", action="store", help="custom options" ) python-cmake-pytest-cmake-702cb04/test/06-extra-args/custom_args/000077500000000000000000000000001512605752200246525ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/06-extra-args/custom_args/test_custom_args.py000066400000000000000000000004041512605752200306070ustar00rootroot00000000000000import pytest def test_requires_cmdopt(request): """Fails unless '--cmdopt=' is passed to pytest.""" if request.config.getoption("--cmdopt") is None: pytest.fail("Test requires '--cmdopt' to properly execute the test.") assert True python-cmake-pytest-cmake-702cb04/test/06-extra-args/test_args.py000066400000000000000000000004251512605752200246720ustar00rootroot00000000000000import pytest def test_requires_no_capture(request): """Fails unless '--capture=no' is passed to pytest.""" if "--capture=no" not in request.config.invocation_params.args: pytest.fail("Test requires '--capture=no' to properly display output.") assert True python-cmake-pytest-cmake-702cb04/test/07-working-directory/000077500000000000000000000000001512605752200237325ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/07-working-directory/CMakeLists.txt000066400000000000000000000004561512605752200264770ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestWorkingDirectory) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests( TestWorkingDirectory WORKING_DIRECTORY subdir ) pytest_discover_tests( TestWorkingDirectory.Bundled WORKING_DIRECTORY subdir BUNDLE_TESTS ) python-cmake-pytest-cmake-702cb04/test/07-working-directory/subdir/000077500000000000000000000000001512605752200252225ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/07-working-directory/subdir/test_correct.py000066400000000000000000000000531512605752200302720ustar00rootroot00000000000000def test_addition(): assert 1 + 1 == 2 python-cmake-pytest-cmake-702cb04/test/07-working-directory/test_incorrect.py000066400000000000000000000001001512605752200273220ustar00rootroot00000000000000raise RuntimeError("This test files should have been excluded") python-cmake-pytest-cmake-702cb04/test/08-test-paths/000077500000000000000000000000001512605752200223455ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/08-test-paths/CMakeLists.txt000066400000000000000000000052031512605752200251050ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(TestCustomPaths) find_package(Pytest REQUIRED) enable_testing() pytest_discover_tests( TestCustomPaths.FromConfig ) set(EXPECTED "TestCustomPaths.FromConfig.test_addition" "TestCustomPaths.FromConfig.test_concat" "TestCustomPaths.FromConfig.test_power" "TestCustomPaths.FromConfig.test_substraction" "TestCustomPaths.FromConfig.test_upper" ) add_test(NAME TestCustomPaths.Validate.FromConfig COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestCustomPaths.FromConfig" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestCustomPaths.BundledFromConfig BUNDLE_TESTS ) set(EXPECTED "TestCustomPaths.BundledFromConfig" ) add_test(NAME TestCustomPaths.Validate.BundledFromConfig COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestCustomPaths.BundledFromConfig" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestCustomPaths.FilePaths TEST_PATHS ${CMAKE_CURRENT_LIST_DIR}/test_a/math/test_add.py test_a/choice.py test_b/test_concat.py ) set(EXPECTED "TestCustomPaths.FilePaths.test_addition" "TestCustomPaths.FilePaths.test_concat" "TestCustomPaths.FilePaths.test_random" ) add_test(NAME TestCustomPaths.Validate.FilePaths COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestCustomPaths.FilePaths" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestCustomPaths.DirPaths TEST_PATHS test_a ${CMAKE_CURRENT_LIST_DIR}/test_b/math ) set(EXPECTED "TestCustomPaths.DirPaths.test_addition" "TestCustomPaths.DirPaths.test_power" "TestCustomPaths.DirPaths.test_substraction" "TestCustomPaths.DirPaths.test_upper" ) add_test(NAME TestCustomPaths.Validate.DirPaths COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestCustomPaths.DirPaths" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) pytest_discover_tests( TestCustomPaths.WithWorkingDirectory TEST_PATHS math choice.py WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test_a ) set(EXPECTED "TestCustomPaths.WithWorkingDirectory.test_addition" "TestCustomPaths.WithWorkingDirectory.test_random" ) add_test(NAME TestCustomPaths.Validate.WithWorkingDirectory COMMAND ${CMAKE_COMMAND} -D "TEST_PREFIX=TestCustomPaths.WithWorkingDirectory" -D "EXPECTED=${EXPECTED}" -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake ) python-cmake-pytest-cmake-702cb04/test/08-test-paths/pytest.ini000066400000000000000000000000531512605752200243740ustar00rootroot00000000000000[pytest] testpaths = test_a test_b python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_a/000077500000000000000000000000001512605752200236245ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_a/choice.py000066400000000000000000000001231512605752200254240ustar00rootroot00000000000000import random def test_random(): assert random.choice([1, 2, 3]) in (1, 2, 3) python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_a/math/000077500000000000000000000000001512605752200245555ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_a/math/test_add.py000066400000000000000000000000531512605752200267140ustar00rootroot00000000000000def test_addition(): assert 1 + 1 == 2 python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_a/test_upper.py000066400000000000000000000000701512605752200263650ustar00rootroot00000000000000def test_upper(): assert "hello".upper() == "HELLO" python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_b/000077500000000000000000000000001512605752200236255ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_b/math/000077500000000000000000000000001512605752200245565ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_b/math/test_power.py000066400000000000000000000000511512605752200273170ustar00rootroot00000000000000def test_power(): assert 2 ** 3 == 8 python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_b/math/test_subtract.py000066400000000000000000000000571512605752200300200ustar00rootroot00000000000000def test_substraction(): assert 2 - 1 == 1 python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_b/test_concat.py000066400000000000000000000000701512605752200265020ustar00rootroot00000000000000def test_concat(): assert "foo" + "bar" == "foobar" python-cmake-pytest-cmake-702cb04/test/08-test-paths/test_incorrect.py000066400000000000000000000001001512605752200257350ustar00rootroot00000000000000raise RuntimeError("This test files should have been excluded") python-cmake-pytest-cmake-702cb04/test/CMakeLists.txt000066400000000000000000000053721512605752200225730ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) project(Test) enable_testing() include(ExternalProject) add_test( NAME TestVersionFails COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/tests/00-version-fails -B ${CMAKE_BINARY_DIR}/_deps/00-version-fails ) set_tests_properties(TestVersionFails PROPERTIES WILL_FAIL TRUE) ExternalProject_Add( TestModifyName SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/01-modify-name BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/01-modify-name BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV -R ModifyName.Validate ) ExternalProject_Add( TestLibraryPath SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/02-library-path BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/02-library-path BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) ExternalProject_Add( TestPythonPath SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/03-python-path BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/03-python-path BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) ExternalProject_Add( TestEnvironment SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/04-environment BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/04-environment BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) ExternalProject_Add( TestProperties SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/05-properties BINARY_DIR ${CMAKE_BINARY_DIR}/_deps/05-properties BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV -R TestProperties.Validate ) ExternalProject_Add( TestExtraArgs SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/06-extra-args BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/06-extra-args BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) ExternalProject_Add( TestWorkingDirectory SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/07-working-directory BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/07-working-directory BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) ExternalProject_Add( TestCustomPaths SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/08-test-paths BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/08-test-paths BUILD_COMMAND ${CMAKE_COMMAND} --build INSTALL_COMMAND "" TEST_COMMAND ${CMAKE_CTEST_COMMAND} -C Release -VV ) python-cmake-pytest-cmake-702cb04/test/utils/000077500000000000000000000000001512605752200211645ustar00rootroot00000000000000python-cmake-pytest-cmake-702cb04/test/utils/compare_discovered_tests.cmake000066400000000000000000000015231512605752200272460ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.20) execute_process( COMMAND ${CMAKE_CTEST_COMMAND} --show-only -R "${TEST_PREFIX}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE test_output ) string(REGEX MATCHALL "${TEST_PREFIX}[^\n]*" discovered_tests "${test_output}") if (NOT discovered_tests) message(FATAL_ERROR "'${TEST_PREFIX}': No tests discovered.") endif() list(SORT discovered_tests) list(SORT EXPECTED) string(JOIN ";" discovered_tests_string ${discovered_tests}) string(JOIN ";" expected_tests_string ${EXPECTED}) if(NOT "${discovered_tests_string}" STREQUAL "${expected_tests_string}") message(FATAL_ERROR "'${TEST_PREFIX}': The discovered tests list does not match the expected list.\n" "Expected: ${expected_tests_string}\n" "Found: ${discovered_tests_string}" ) endif()