-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Keyword selection expressions are limited to python syntax, which excludes some nodeids #1141
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
Comments
The current mark keyword evaluator uses python syntax, |
So, in the above example, is there a way to select and run just the test, "test_me[spam eggs]" ? |
The exact test can be selected by nodeid just use |
To summarise, as of pytest 3.9.1:
The root cause is this code (updated link), which chokes when trying to |
We don't have a replacement lined up yet |
Previously, the expressions given to the `-m` and `-k` options were evaluated with `eval`. This causes a few issues: - Python keywords cannot be used. - Constants like numbers, None, True, False are not handled correctly. - Various syntax like numeric operators and `X if Y else Z` is supported unintentionally. - `eval()` is somewhat dangerous for arbitrary input. - Can fail in many ways so requires `except Exception`. The format we want to support is quite simple, so change to a custom parser. This fixes the issues above, and gives us full control of the format, so can be documented comprehensively and even be extended in the future if we wish. Fixes pytest-dev#1141. Fixes pytest-dev#3573. Fixes pytest-dev#5881. Fixes pytest-dev#6822. Fixes pytest-dev#7112.
Previously, the expressions given to the `-m` and `-k` options were evaluated with `eval`. This causes a few issues: - Python keywords cannot be used. - Constants like numbers, None, True, False are not handled correctly. - Various syntax like numeric operators and `X if Y else Z` is supported unintentionally. - `eval()` is somewhat dangerous for arbitrary input. - Can fail in many ways so requires `except Exception`. The format we want to support is quite simple, so change to a custom parser. This fixes the issues above, and gives us full control of the format, so can be documented comprehensively and even be extended in the future if we wish. Fixes pytest-dev#1141. Fixes pytest-dev#3573. Fixes pytest-dev#5881. Fixes pytest-dev#6822. Fixes pytest-dev#7112.
Hi there.
py.test is fantastic!
I'm wondering if the following is an error, or, expected behaviour:
With the following:
This works fine:
py.test -k 'test_me[ham]'
While the following triggers an internal error / syntax error:
py.test -k 'test_me[spam eggs]'
Looks like condition here:
https://github.com/pytest-dev/pytest/blob/master/_pytest/mark.py#L154
prevents any matching on parameters having spaces in them (and falls through to an eval() call).
The text was updated successfully, but these errors were encountered: