question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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=False)¶
pytest.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!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
symonkcommented, Jul 28, 2021

Thanks all, I will carve out some time tonight after work to attempt to unify reason= across the board in places, I have made a start. After I have a few PRs i will look at initially creating follow up PRs to move plugins inside pytest-dev/ using msg= explicitly to use reason= or pass w/o keyword.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use skip and xfail to deal with tests that cannot succeed
The simplest way to skip a test function is to mark it with the skip decorator which may be passed an optional reason...
Read more >
pytest Documentation - Read the Docs
2.13 How to use skip and xfail to deal with tests that cannot succeed . ... failure message. pytest only rewrites test modules...
Read more >
Pytest - skip (xfail) mixed with parametrize - Stack Overflow
I added a @pytest.mark.incrementalparam to achieve this. ... be used without parametrize cause parametrize annotation creates automatically _genid variable.
Read more >
pytest Changelog - pyup.io
signatures now accept a ``reason`` argument instead of ``msg``. ... This was changed for consistency with :func:`pytest.mark.skip <pytest.mark.skip>` and ...
Read more >
Contributing to the code base - Pandas
This ensures a consistent error message when the dependency is not met. ... Use pytest.mark.skip when a test case is never expected to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found