Skip to content

Support pytest markers regardless of decorator order#3888

Open
igorts-git wants to merge 1 commit into
mainfrom
fix-parameterized-marker-ordering
Open

Support pytest markers regardless of decorator order#3888
igorts-git wants to merge 1 commit into
mainfrom
fix-parameterized-marker-ordering

Conversation

@igorts-git
Copy link
Copy Markdown
Collaborator

Description

The problem

Without this patch unit tests that set cpu_only would still execute on TPU and GPU machines if they are applied on top of a @parameterized.named_parameters(...) decorator.

For instance:

  @pytest.mark.cpu_only
  @parameterized.named_parameters(...)
  def test_foo(self, ...):

Solution

We ensure pytest markers that are applied above @parameterized.named_parameters are 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):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...t/integration/vllm/maxtext_vllm_adapter/adapter.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

🤖 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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 📋 Review Summary

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.py is 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


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Comment thread tests/conftest.py Outdated
@igorts-git igorts-git force-pushed the fix-parameterized-marker-ordering branch from 8f61ecf to a37596b Compare May 13, 2026 21:30
…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.
@igorts-git igorts-git force-pushed the fix-parameterized-marker-ordering branch from a37596b to f805d4d Compare May 13, 2026 21:40
@igorts-git igorts-git closed this May 14, 2026
@igorts-git igorts-git reopened this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants