-
Notifications
You must be signed in to change notification settings - Fork 28
repeat tests change to happen after -k #88
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some unitzests and currently completely misshandles complex keyword expressions
An expression with or would break the current simplified handling
We might want to upstream this optimization to pytest core for marker and keyword expressions to avoid generate tests altogether for deselected items
However the general case has some extra caveats about selection criteria potentially being part of the parameterset
For the case of keyword this is less of an issue with the caveats that markers from parametersets are part of the complete keyword set creating a slight potential for false negatives
I both agree with @RonnyPfannschmidt and think this is important to get to working. I'm wondering if, as a temporary hack until pytest core can deal with this properly, we can pre-apply keyword and marker deselection before applying multiplication in this plugin. I don't know if it's possible, but it might be worth a try. @clemente0731, is that something you'd be willing to try, along with adding some more complex keyword and marker tests? |
Well its going to need some hacks so it depends Off hand its unclear how fragile this will be |
I'll give it a try and then update the results here. However, it might take a while as I'm quite busy with work this week. Ha~ |
Already tried the pytest_collection_modifyitems method, but unfortunately, it seems that it cannot take effect before collection. |
The recommendation was to invoke the logic skip/deselect do in generate tests instead of modifyitems |
I think this would be conceptually possible, but only for someone familiar with the AST and the parsing bits of deselect_by_keyword and deslect_by_mark. Unless I'm mistaken, it looks like we'd have to re-implement something like deselect_by_keyword and deslect_by_mark to be used within pytest_genarate_tests in the plugin, to see if a test is likely to be selected or deselected, and then only repeat tests that are going to be selected. The reimplementation seems necessary to apply the filtering from metafunc in pytest_generate_tests, as "items" is not available via metafunc, this will be difficult. It seems like the right answer is for pytest to apply filtering via deselect_by_keyword and deslect_by_mark twice:
A viable way to implement this within the pytest-repeat plugin eludes me. I recommend closing this issue as "will not fix" |
Didn't intend to close it right now, I was hoping to get @RonnyPfannschmidt or others feedback first |
repeat tests change to happen after -k
Based on actual measurements under tests , the performance will be improved by at least 2x to 10x.
This change will optimize the performance of repeat cases, especially when there are a huge number of tests. If the "-k" option exists, only the cases matched by "-k" will be repeated.
after optimize --> 18 passed, 9 deselected in 0.01s
before optimize --> 18 passed, 162 deselected in 0.02s
pytest -s --count 1 --collect-only -q