pytest-dev/pytest-cpp

Catch2: escape special characters in test names

gmgunter opened this issue · 1 comments

When specifying which tests to run from the command line, Catch2 treats some characters specially. For example, * is a wildcard character, ~ negates a test spec, etc.

However, these literal characters can also appear in test names. In order to match a specific test name that contains one or more special characters, they need to be escaped with a preceding backslash ("\").

You can also match test names with special characters by escaping them with a backslash ("\"), e.g. a test named "Do A, then B" is matched by "Do A, then B" test spec. Backslash also escapes itself.

(reference)

Currently, pytest-cpp reports a test failure for any tests with special characters in their name, with the following error message:

Internal Error: could not find test <test_id> in results:
:0: C++ failure

I believe this issue may be resolved by escaping any special characters in the test_id before invoking the test executable.

I'm happy to work on resolving this -- just want to make sure a fix would be welcome before making the effort to submit a PR.

I'm happy to work on resolving this -- just want to make sure a fix would be welcome before making the effort to submit a PR.

Yes thanks @gmgunter, that would be appreciated. 👍