Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape arguments to macro call 'create_test' #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/PytestAddTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
# Macro to create individual tests with optional test properties.
macro(create_test NAME IDENTIFIER)
string(APPEND _content
"add_test(\"${NAME}\" \"${PYTEST_EXECUTABLE}\" \"${IDENTIFIER}\")\n"
"add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==])\n"
)

# Prepare the properties for the test, including the environment settings.
Expand All @@ -50,7 +50,7 @@ if(CMAKE_SCRIPT_MODE_FILE)

# If tests are bundled together, create a single test group.
if (BUNDLE_TESTS)
create_test("${TEST_GROUP_NAME}" "${WORKING_DIRECTORY}")
create_test("\${TEST_GROUP_NAME}" "\${WORKING_DIRECTORY}")

else()
# Set environment variables for collecting tests.
Expand Down Expand Up @@ -133,7 +133,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
set(test_case "${WORKING_DIRECTORY}/${line}")

# Create the test for CTest.
create_test("${test_name}" "${test_case}")
create_test("\${test_name}" "\${test_case}")
endforeach()

# Warn if no tests were discovered.
Expand Down
6 changes: 6 additions & 0 deletions test/01-modify-name/test_math_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ def test_subtraction():
])
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