pytest-cmake 0.5.2__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytest-cmake
3
- Version: 0.5.2
3
+ Version: 0.7.0
4
4
  Summary: Provide CMake module for Pytest
5
+ Project-URL: Documentation, https://python-cmake.github.io/pytest-cmake
6
+ Project-URL: Repository, https://github.com/python-cmake/pytest-cmake
7
+ Project-URL: Issues, https://github.com/python-cmake/pytest-cmake/issues
8
+ Project-URL: Changelog, https://python-cmake.github.io/pytest-cmake/release/release_notes.html
5
9
  Author-email: Jeremy Retailleau <jeremy.retailleau@gmail.com>
6
10
  License: MIT License
7
11
 
@@ -46,8 +50,7 @@ Description-Content-Type: text/markdown
46
50
 
47
51
  [![PyPi version](https://img.shields.io/pypi/v/pytest-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/pytest-cmake)
48
52
  [![CMake](https://img.shields.io/badge/CMake-3.20...3.29-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
49
- [![Documentation](https://readthedocs.org/projects/pytest-cmake/badge/?version=stable)](https://pytest-cmake.readthedocs.io/en/stable/)
50
- [![Test](https://github.com/buddly27/pytest-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/buddly27/pytest-cmake/actions/workflows/test.yml)
53
+ [![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)
51
54
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
55
 
53
56
  This project provides convenient ways to use [Pytest](https://docs.pytest.org/)
@@ -57,12 +60,12 @@ versions on Linux, macOS or Windows using the
57
60
  function:
58
61
 
59
62
  ```cmake
60
- find_package(Pytest 4.6.11 REQUIRED)
63
+ find_package(Pytest 8.2.1 REQUIRED)
61
64
  ```
62
65
 
63
66
  A ``pytest_discover_tests`` function is provided to simplify automatic
64
67
  testing for C++ projects with Python bindings. It can create CTest tests
65
- for each Python test collected within a correct environment:
68
+ for each Python test collected within a controlled environment:
66
69
 
67
70
  ```cmake
68
71
  pytest_discover_tests(
@@ -92,4 +95,4 @@ Running the tests will display the status for each test collected as follows:
92
95
  ## Documentation
93
96
 
94
97
  Full documentation, including installation and setup guides, can be found at
95
- https://pytest-cmake.readthedocs.io/en/stable/
98
+ https://python-cmake.github.io/pytest-cmake/
@@ -2,8 +2,7 @@
2
2
 
3
3
  [![PyPi version](https://img.shields.io/pypi/v/pytest-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/pytest-cmake)
4
4
  [![CMake](https://img.shields.io/badge/CMake-3.20...3.29-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
5
- [![Documentation](https://readthedocs.org/projects/pytest-cmake/badge/?version=stable)](https://pytest-cmake.readthedocs.io/en/stable/)
6
- [![Test](https://github.com/buddly27/pytest-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/buddly27/pytest-cmake/actions/workflows/test.yml)
5
+ [![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)
7
6
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
7
 
9
8
  This project provides convenient ways to use [Pytest](https://docs.pytest.org/)
@@ -13,12 +12,12 @@ versions on Linux, macOS or Windows using the
13
12
  function:
14
13
 
15
14
  ```cmake
16
- find_package(Pytest 4.6.11 REQUIRED)
15
+ find_package(Pytest 8.2.1 REQUIRED)
17
16
  ```
18
17
 
19
18
  A ``pytest_discover_tests`` function is provided to simplify automatic
20
19
  testing for C++ projects with Python bindings. It can create CTest tests
21
- for each Python test collected within a correct environment:
20
+ for each Python test collected within a controlled environment:
22
21
 
23
22
  ```cmake
24
23
  pytest_discover_tests(
@@ -48,4 +47,4 @@ Running the tests will display the status for each test collected as follows:
48
47
  ## Documentation
49
48
 
50
49
  Full documentation, including installation and setup guides, can be found at
51
- https://pytest-cmake.readthedocs.io/en/stable/
50
+ https://python-cmake.github.io/pytest-cmake/
@@ -60,41 +60,35 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest)
60
60
  "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;DEPENDS"
61
61
  )
62
62
 
63
- # Set library path depending on the platform.
63
+ # Identify library path environment name depending on the platform.
64
64
  if (CMAKE_SYSTEM_NAME STREQUAL Windows)
65
- set(LIB_ENV_PATH PATH)
66
- set(_env_sep "\\\;")
65
+ set(LIBRARY_ENV_NAME PATH)
67
66
  elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
68
- set(LIB_ENV_PATH DYLD_LIBRARY_PATH)
69
- set(_env_sep ":")
67
+ set(LIBRARY_ENV_NAME DYLD_LIBRARY_PATH)
70
68
  else()
71
- set(LIB_ENV_PATH LD_LIBRARY_PATH)
72
- set(_env_sep ":")
69
+ set(LIBRARY_ENV_NAME LD_LIBRARY_PATH)
73
70
  endif()
74
71
 
75
- # Convert all paths into cmake paths.
76
- cmake_path(CONVERT "$ENV{${LIB_ENV_PATH}}" TO_CMAKE_PATH_LIST libpath)
77
- cmake_path(CONVERT "$ENV{PYTHONPATH}" TO_CMAKE_PATH_LIST pythonpath)
72
+ # Sanitize all paths for CMake.
73
+ cmake_path(CONVERT "$ENV{${LIBRARY_ENV_NAME}}" TO_CMAKE_PATH_LIST LIBRARY_PATH)
74
+ cmake_path(CONVERT "$ENV{PYTHONPATH}" TO_CMAKE_PATH_LIST PYTHON_PATH)
78
75
 
79
- # Prepend input path to environment variables
76
+ # Prepend input path to environment variables.
80
77
  if (_LIBRARY_PATH_PREPEND)
81
78
  list(REVERSE _LIBRARY_PATH_PREPEND)
82
79
  foreach (_path ${_LIBRARY_PATH_PREPEND})
83
- set(libpath "${_path}" "${libpath}")
80
+ set(LIBRARY_PATH "${_path}" "${LIBRARY_PATH}")
84
81
  endforeach()
85
82
  endif()
86
83
 
87
84
  if (_PYTHON_PATH_PREPEND)
88
85
  list(REVERSE _PYTHON_PATH_PREPEND)
89
86
  foreach (_path ${_PYTHON_PATH_PREPEND})
90
- set(pythonpath "${_path}" "${pythonpath}")
87
+ set(PYTHON_PATH "${_path}" "${PYTHON_PATH}")
91
88
  endforeach()
92
89
  endif()
93
90
 
94
- # Convert list into string.
95
- list(JOIN libpath "${_env_sep}" libpath)
96
- list(JOIN pythonpath "${_env_sep}" pythonpath)
97
-
91
+ # Default working directory to current build path if none is provided.
98
92
  if (NOT _WORKING_DIRECTORY)
99
93
  set(_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
100
94
  endif()
@@ -116,9 +110,9 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest)
116
110
  -D "PYTEST_EXECUTABLE=${PYTEST_EXECUTABLE}"
117
111
  -D "TEST_GROUP_NAME=${NAME}"
118
112
  -D "BUNDLE_TESTS=${_BUNDLE_TESTS}"
119
- -D "LIB_ENV_PATH=${LIB_ENV_PATH}"
120
- -D "LIBRARY_PATH=${libpath}"
121
- -D "PYTHON_PATH=${pythonpath}"
113
+ -D "LIBRARY_ENV_NAME=${LIBRARY_ENV_NAME}"
114
+ -D "LIBRARY_PATH=${LIBRARY_PATH}"
115
+ -D "PYTHON_PATH=${PYTHON_PATH}"
122
116
  -D "TRIM_FROM_NAME=${_TRIM_FROM_NAME}"
123
117
  -D "WORKING_DIRECTORY=${_WORKING_DIRECTORY}"
124
118
  -D "ENVIRONMENT=${_ENVIRONMENT}"
@@ -6,10 +6,17 @@ if(CMAKE_SCRIPT_MODE_FILE)
6
6
  # Set Cmake test file to execute each test.
7
7
  set(_content "")
8
8
 
9
- # Ensure that list environment variables are
10
- # represented as a string on Windows.
11
- string(REPLACE [[;]] [[\;]] LIBRARY_PATH "${LIBRARY_PATH}")
12
- string(REPLACE [[;]] [[\;]] PYTHON_PATH "${PYTHON_PATH}")
9
+ cmake_path(CONVERT "${LIBRARY_PATH}" TO_NATIVE_PATH_LIST LIBRARY_PATH)
10
+ cmake_path(CONVERT "${PYTHON_PATH}" TO_NATIVE_PATH_LIST PYTHON_PATH)
11
+
12
+ # Serialize path values separated by semicolons (required on Windows).
13
+ macro(encode_value VARIABLE_NAME)
14
+ string(REPLACE [[\]] [[\\]] ${VARIABLE_NAME} "${${VARIABLE_NAME}}")
15
+ string(REPLACE [[;]] [[\\;]] ${VARIABLE_NAME} "${${VARIABLE_NAME}}")
16
+ endmacro()
17
+
18
+ encode_value(LIBRARY_PATH)
19
+ encode_value(PYTHON_PATH)
13
20
 
14
21
  if (BUNDLE_TESTS)
15
22
  string(APPEND _content
@@ -19,7 +26,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
19
26
  ")\n"
20
27
  "set_tests_properties(\n"
21
28
  " \"${TEST_GROUP_NAME}\" PROPERTIES\n"
22
- " ENVIRONMENT \"${LIB_ENV_PATH}=${LIBRARY_PATH}\"\n"
29
+ " ENVIRONMENT \"${LIBRARY_ENV_NAME}=${LIBRARY_PATH}\"\n"
23
30
  ")\n"
24
31
  "set_tests_properties(\n"
25
32
  " \"${TEST_GROUP_NAME}\"\n"
@@ -29,6 +36,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
29
36
  )
30
37
 
31
38
  foreach(env ${ENVIRONMENT})
39
+ encode_value(env)
32
40
  string(APPEND _content
33
41
  "set_tests_properties(\n"
34
42
  " \"${TEST_GROUP_NAME}\"\n"
@@ -40,7 +48,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
40
48
 
41
49
  else()
42
50
  # Set environment for collecting tests.
43
- set(ENV{${LIB_ENV_PATH}} "${LIBRARY_PATH}")
51
+ set(ENV{${LIBRARY_ENV_NAME}} "${LIBRARY_PATH}")
44
52
  set(ENV{PYTHONPATH} "${PYTHON_PATH}")
45
53
  set(ENV{PYTHONWARNINGS} "ignore")
46
54
 
@@ -78,17 +86,18 @@ if(CMAKE_SCRIPT_MODE_FILE)
78
86
  set(_class ${CMAKE_MATCH_3})
79
87
  set(_func ${CMAKE_MATCH_4})
80
88
 
89
+ if (TRIM_FROM_NAME)
90
+ set(pattern "${TRIM_FROM_NAME}")
91
+ string(REGEX REPLACE "${pattern}" "" _class "${_class}")
92
+ string(REGEX REPLACE "${pattern}" "" _func "${_func}")
93
+ endif()
94
+
81
95
  if (_class)
82
96
  set(test_name "${_class}.${_func}")
83
97
  else()
84
98
  set(test_name "${_func}")
85
99
  endif()
86
100
 
87
- if (TRIM_FROM_NAME)
88
- string(REGEX REPLACE
89
- "${TRIM_FROM_NAME}" "" test_name "${test_name}")
90
- endif()
91
-
92
101
  set(test_name "${TEST_GROUP_NAME}.${test_name}")
93
102
  set(test_case "${WORKING_DIRECTORY}/${line}")
94
103
 
@@ -99,7 +108,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
99
108
  ")\n"
100
109
  "set_tests_properties(\n"
101
110
  " \"${test_name}\" PROPERTIES\n"
102
- " ENVIRONMENT \"${LIB_ENV_PATH}=${LIBRARY_PATH}\"\n"
111
+ " ENVIRONMENT \"${LIBRARY_ENV_NAME}=${LIBRARY_PATH}\"\n"
103
112
  ")\n"
104
113
  "set_tests_properties(\n"
105
114
  " \"${test_name}\"\n"
@@ -109,6 +118,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
109
118
  )
110
119
 
111
120
  foreach(env ${ENVIRONMENT})
121
+ encode_value(env)
112
122
  string(APPEND _content
113
123
  "set_tests_properties(\n"
114
124
  " \"${test_name}\"\n"
@@ -9,7 +9,7 @@ backend-path = ["."]
9
9
 
10
10
  [project]
11
11
  name = "pytest-cmake"
12
- version = "0.5.2"
12
+ version = "0.7.0"
13
13
  description = "Provide CMake module for Pytest"
14
14
  readme = "README.md"
15
15
  requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
@@ -36,6 +36,12 @@ classifiers = [
36
36
  "Programming Language :: Python :: 3.12",
37
37
  ]
38
38
 
39
+ [project.urls]
40
+ Documentation = "https://python-cmake.github.io/pytest-cmake"
41
+ Repository = "https://github.com/python-cmake/pytest-cmake"
42
+ Issues = "https://github.com/python-cmake/pytest-cmake/issues"
43
+ Changelog = "https://python-cmake.github.io/pytest-cmake/release/release_notes.html"
44
+
39
45
  [tool.hatch.build.hooks.custom]
40
46
  require-runtime-dependencies = true
41
47
  path = "build_config.py"
@@ -60,7 +60,7 @@ class CreateCmakeConfig(install):
60
60
 
61
61
  setup(
62
62
  name="pytest-cmake",
63
- version="0.5.2",
63
+ version="0.7.0",
64
64
  data_files=[
65
65
  (
66
66
  "share/Pytest/cmake",
File without changes
File without changes