Skip to content

pytest.skip: Rename "msg" to "reason" for consistency with pytest.mark.skip/xfail? #8948

@The-Compiler

Description

@The-Compiler

The signature of pytest.skip is:

skip(msg[, allow_module_level=False])

but the signature of pytest.xfail is:

xfail(reason='')

Marks (pytest.mark.skip, pytest.mark.skipif and pytest.mark.xfail) use reason too:

pytest.mark.skipif(condition, *, reason=None)
pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=Falsepytest.mark.skipif(condition, *, reason=None

Note that pytest.fail uses msg:

fail(msg='', pytrace=True)

but at least from an user perspective, skip is probably closer to xfail and mark.skip / mark.skipif / mark.xfail.

Should we rename the msg argument for pytest.skip to reason for consistency (with a deprecation for the old name), or isn't that worth the trouble?

Thanks to Francesco Casalegno for reporting this in the pytest training I gave at Europython 2021 today!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelogtype: deprecationfeature that will be removed in the futuretype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions