-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
By default pytest 6.2.2 parametrize does user arguments to generate IDs, but some of these ids cannot be used with -k
option because you endup with errors like unexpected character "/"
when trying to do so.
The solution for this bug is to assure that auto-generated IDs are sanitized so they can be used with -k option.
Example:
@pytest.mark.parametrize(
('path', 'kind'),
(
("foo/playbook.yml", "playbook"),
),
)
def test_auto_detect(path: str, kind: FileType) -> None:
...
As you can see the first parameter includes a slash, and for good reasons. It is far from practical to have to add custom "ids" for all of these, as you can have LOTS of them.
There is another annoyance related to the -k selecting for parameterized tests, is the fact that square braces []
have special meanings for some shells and in order to use it you must remember to quote the strings. It would be much easier if the display and selecting of parametrized tests would use only shell-safe format, so we can easily copy/paste a failed test in run it. For example I think that using colon would be safe and arguably even easier to read: test_name:param1:param2
.