Support pytest markers regardless of decorator order#3888
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
0abcaf4 to
76e7b00
Compare
21e55fc to
44f6859
Compare
|
🤖 Hi @igorts-git, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
This Pull Request introduces a clever fix for pytest marker propagation issues when using @parameterized.named_parameters from absl-py. By monkeypatching the _ParameterizedTestIter class in conftest.py, it ensures that markers like @pytest.mark.cpu_only are correctly passed down to generated test methods regardless of their position in the decorator stack.
🔍 General Feedback
- The solution is elegant and addresses a significant pain point in the project's testing workflow.
- The inclusion of
marker_propagation_test.pyis highly appreciated as it empirically validates the fix. - Minor suggestions were made to improve the robustness of the monkeypatching logic and simplify the attribute merging.
|
|
||
| return wrapper | ||
|
|
||
|
|
There was a problem hiding this comment.
🟢 Excellent addition of a dedicated test to verify marker propagation. This ensures the monkeypatch works as expected and provides a regression test for any future changes to the testing infrastructure.
8f61ecf to
a37596b
Compare
…rator stack order Ensures pytest markers applied above @parameterized.named_parameters are properly propagated to generated test methods during class metaclass expansion. Includes unit tests validating marker propagation across both parameterized and standard decorator stacks.
a37596b to
f805d4d
Compare
Description
The problem
Without this patch unit tests that set
cpu_onlywould still execute on TPU and GPU machines if they are applied on top of a@parameterized.named_parameters(...)decorator.For instance:
Solution
We ensure pytest markers that are applied above
@parameterized.named_parametersare properly propagated to generated test methods during class metaclass expansion.Tests
I added unit tests for validating marker propagation across both parameterized and standard decorator stacks.
To confirm that this unit test fails without applying the patch I created a separate PR with just the unit test and without the patch: #3887. We expect the test to fail on that PR and pass on this PR.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.