Skip to content

docs: document multiple positional conditions for skipif/xfail - #14802

Open
gleecode04 wants to merge 1 commit into
pytest-dev:mainfrom
gleecode04:docs/skipif-xfail-multiple-conditions
Open

docs: document multiple positional conditions for skipif/xfail#14802
gleecode04 wants to merge 1 commit into
pytest-dev:mainfrom
gleecode04:docs/skipif-xfail-multiple-conditions

Conversation

@gleecode04

@gleecode04 gleecode04 commented Jul 30, 2026

Copy link
Copy Markdown

This PR fixes the documented signatures for pytest.mark.skipif and pytest.mark.xfail to reflect the codebase: both accept multiple positional condition arguments, not just one, and the test is skipped/xfailed if any of them evaluate to True.

  • pytest.mark.skipif(condition, *conditions, reason=None), was missing *conditions.
  • pytest.mark.xfail(condition=True, *conditions, reason=None, raises=None, run=True, strict=strict_xfail), same.

The behavior already existed (evaluate_skip_marks/evaluate_xfail_marks in src/_pytest/skipping.py loop over mark.args), it just wasn't documented, and no existing test called either mark with more than one positional condition in a single invocation, so I added regression tests for that in testing/test_skipping.py.

No changelog entry, per CONTRIBUTING.rst's exemption for doc-only fixes that don't change documented behavior.

I used AI assistance (Claude) to research this repo and prepare the change, then reviewed the diff, reproduced the behavior myself, and ran the full test_skipping.py suite plus a local docs build before opening this. Happy to answer questions on any part of it.

pytest.mark.skipif and pytest.mark.xfail both accept multiple
positional condition arguments (the test is skipped/xfailed if any
evaluate to True), as already stated in the internal marker
registration message and encoded in the type stubs. The reference
docs only showed a single `condition` parameter and never mentioned
this. Also add regression tests, since no test previously exercised
multiple conditions passed to a single mark call (only stacking
separate mark decorators was covered).

@RonnyPfannschmidt RonnyPfannschmidt 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.

At first glance this makes everything worse

Both the test cases and the documentation changes add confusion to something that needs discussion first

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.

2 participants