Deprecation of msg= for both pytest.skip() and pytest.fail(). (#8950)
* porting pytest.skip() to use reason=, adding tests * avoid adding **kwargs, it breaks other functionality, use optional msg= instead * deprecation of `pytest.fail(msg=...)` * fix bug with not capturing the returned reason value * pass reason= in acceptance async tests instead of msg= * finalising deprecations of `msg` in `pytest.skip()` and `pytest.fail()` * Update doc/en/deprecations.rst Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com> * Update doc/en/deprecations.rst Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com> * fix failing test after upstream merge * adding deprecation to `pytest.exit(msg=...)` * add docs for pytest.exit deprecations * finalising deprecation of msg for pytest.skip, pytest.exit and pytest.fail * hold a reference to the Scope instance to please mypy Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
@@ -200,6 +200,64 @@ def test_warns_none_is_deprecated():
|
||||
pass
|
||||
|
||||
|
||||
class TestSkipMsgArgumentDeprecated:
|
||||
def test_skip_with_msg_is_deprecated(self, pytester: Pytester) -> None:
|
||||
p = pytester.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
|
||||
def test_skipping_msg():
|
||||
pytest.skip(msg="skippedmsg")
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest(p)
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"*PytestDeprecationWarning: pytest.skip(msg=...) is now deprecated, "
|
||||
"use pytest.skip(reason=...) instead",
|
||||
'*pytest.skip(msg="skippedmsg")*',
|
||||
]
|
||||
)
|
||||
result.assert_outcomes(skipped=1, warnings=1)
|
||||
|
||||
def test_fail_with_msg_is_deprecated(self, pytester: Pytester) -> None:
|
||||
p = pytester.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
|
||||
def test_failing_msg():
|
||||
pytest.fail(msg="failedmsg")
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest(p)
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"*PytestDeprecationWarning: pytest.fail(msg=...) is now deprecated, "
|
||||
"use pytest.fail(reason=...) instead",
|
||||
'*pytest.fail(msg="failedmsg")',
|
||||
]
|
||||
)
|
||||
result.assert_outcomes(failed=1, warnings=1)
|
||||
|
||||
def test_exit_with_msg_is_deprecated(self, pytester: Pytester) -> None:
|
||||
p = pytester.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
|
||||
def test_exit_msg():
|
||||
pytest.exit(msg="exitmsg")
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest(p)
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"*PytestDeprecationWarning: pytest.exit(msg=...) is now deprecated, "
|
||||
"use pytest.exit(reason=...) instead",
|
||||
]
|
||||
)
|
||||
result.assert_outcomes(warnings=1)
|
||||
|
||||
|
||||
def test_deprecation_of_cmdline_preparse(pytester: Pytester) -> None:
|
||||
pytester.makeconftest(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user