Skip to content

Parse complete numeric suffixes for order marker prefixes - #269

Merged
mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
ryanduguid:ryan/fix-marker-prefix-parsing
Oct 25, 2026
Merged

mrbean-bremen merged 2 commits into
pytest-dev:mainfrom
ryanduguid:ryan/fix-marker-prefix-parsing

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Parse the complete suffix after --order-marker-prefix as the integer order index. Multi-digit and negative indices now work, whilst bare prefixes and malformed suffixes are ignored by the existing ValueError handler. Explicit order markers retain precedence.

Evidence

  • Before: 5 regression cases failed with the original parser, covering multi-digit indices, a bare prefix, a numeric-leading label and negative indices.
  • After: all 154 tests pass on Windows with Python 3.10/pytest 6.2.4, Python 3.12/pytest 9.1.1 and Python 3.14/pytest 9.1.1. All applicable pre-commit hooks pass.
  • Added coverage includes a zero-index prefix that would expose an explicit-order precedence regression.
  • Upstream CI passes its Linux, Windows and PyPy test matrix, performance checks, documentation build and pre-commit checks.

Risk

Ordering changes for prefixed markers with multi-digit, negative or malformed suffixes; ordinary order markers retain precedence.

Unverified

None.

@codecov-commenter

codecov-commenter commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.21%. Comparing base (e729615) to head (d1a105d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #269   +/-   ##
=======================================
  Coverage   98.21%   98.21%           
=======================================
  Files           5        5           
  Lines         671      673    +2     
  Branches      143      143           
=======================================
+ Hits          659      661    +2     
  Misses          3        3           
  Partials        9        9           

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

Please also update the release notes.

test_marker=f"""
import pytest

@getattr(pytest.mark, "my{suffix}")

@mrbean-bremen mrbean-bremen Oct 25, 2026 •

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.

I'm not very happy that this syntax is needed for negative markers, as this is not intuitive, and most users won't know it. Maybe it would make sense to add some placeholder for the minus (something like _neg or _minus) to make it easier to use (additionally to supporting actual negative numbers).
At least it would make sense to add a note to the documentation describing how negative numbers can be set in a marker.

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've added a neg placeholder: after the prefix, _neg1 or neg1 gives -1, so @pytest.mark.m_neg1 works without getattr. Literal negative suffixes still work. The configuration docs now explain both, and the release notes have an Unreleased entry. Happy to change the spelling to _minus if you prefer.

Document negative indices and add a release note.

@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 a68a7b3 into pytest-dev:main Oct 25, 2026
16 checks passed
@ryanduguid
ryanduguid deleted the ryan/fix-marker-prefix-parsing branch October 27, 2026 01:43
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