-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
keyword-selection mechanism is too fuzzy #387
Comments
Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub): In this specific case one can already select just a single test by using the node ID. Assuming these live in the test_foo file:
or
work fine. And to find out the node IDs one can use |
Original comment by Alfredo Deza (BitBucket: alfredodeza, GitHub: alfredodeza): Specifying a node id like Floris mentions is doable, but only when there are methods/functions that aren't parametrized. As soon as it is parametrized it is impossible as the node ID changes with the values of parametrization (see issue #649 ) If there was a way to tell |
Though the problem is not a big one, I've been running into this issue many times over the years, and my current solution will be to add two underscores to each test name (so that no test name is a prefix for another test name). |
Originally reported by: BitBucket: jenisys, GitHub: jenisys
VERSION: pytest-2.4.2
RELATED: #357
It is currently not possible with py.test to select the exact TestClass/TestMethod (or py.test cannot garantuee it in a general case).
EXAMPLE:
Keyword-selection
py.test -k 'TestAlice and test_foo'
will select both tests and not one. Currently, you have no mean to specify/require and exact match instead of using the "keyword-contained-in" operator.DESIRED:
POTENTIAL SOLUTIONS:
py.test -k '^TestAlice$ and test_foo' …
(exact-match, startswith/endswith for example by using regex-related syntax).fnmatch
patterns, likepy.test -k 'TestAlice* and *_foo'
(but that will break the existing mechanism)py.test -k '@fnmatch:TestAlice* and *_foo'
(where: "@fnmatch:" prefix selects the matching strategy of the keyword expression after the colon). Candidates for keyword-matching strategies:fnmatch
,re
(regular expressions), ...From all proposed solutions above, SOLUTION 3 is probably the most appealing (at least to me), because it gives the user the control to specify what should be done and is extensible for the future (if needed).
IMPACT:
Most of the functionality could easily provided/implemented by extending the
pytest.mark.KeywordMapping
class that is used by the boolean expression evaluator.WORKAROUND:
Normally, you would temporarily add a marker, like "@pytest.mark.wip", to the test of interest. This will allow you to select only the test(s) of interest by using the marker-selection mechanism. But if you cannot/should not modify the test code, you cannot use this solution.
I could implement this extension/enhancement and provide a pull-requests after it is agreed what the desired solution should be (if any).
The text was updated successfully, but these errors were encountered: