Skip to content

Apply chained relative markers between order groups - #279

Merged
mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
Vineet829:group-relative-chain
Nov 23, 2026
Merged

mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
Vineet829:group-relative-chain

Conversation

@Vineet829

Copy link
Copy Markdown
Contributor

GroupSorter.sorted_groups() repeats its passes while relative marks are left and the last pass resolved some, but it never recomputes length inside the loop, so it always stops after one pass. ItemList._apply_iterative() uses the same loop and does update length. move_item() skips a mark while the group it refers to still has a mark of its own pending, so the skipped mark can only be applied in a later pass.

With --order-group-scope=module, test_chain1.py::test_one marked after="test_chain3.py::test_three" and test_chain2.py::test_two marked after="test_chain1.py::test_one", the modules run as chain2, chain3, chain1, with no warning. Classes behave the same with --order-group-scope=class, and before and dependency markers are affected too.

The loop now recomputes length after each pass. I added a module and a class case to tests/test_order_group_scope_relative.py and a changelog line.

@codecov-commenter

codecov-commenter commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.94%. Comparing base (daa1583) to head (8564143).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #279   +/-   ##
=======================================
  Coverage   97.94%   97.94%           
=======================================
  Files           5        5           
  Lines         681      682    +1     
  Branches      144      144           
=======================================
+ Hits          667      668    +1     
  Misses          4        4           
  Partials       10       10           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mrbean-bremen mrbean-bremen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, thanks! Will merge after the release notes are adapted.

Comment thread CHANGELOG.md Outdated
- with `--order-group-scope`, relative and dependency markers between modules
or classes are resolved in repeated passes, so a chain such as A after C,
B after A is now applied; previously only one pass was made and part of such
a chain could be ignored without a warning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please shorten this - no need to exactly describe the behavior before the fix; instead, add a link to the PR (as done in other entries) where the fix is described in detail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I shortened the entry and added a link to the PR.

@mrbean-bremen mrbean-bremen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@mrbean-bremen
mrbean-bremen merged commit 3e4b3a6 into pytest-dev:main Nov 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants