Improve type-checking in OutcomeException (#5580)
Improve type-checking in OutcomeException
This commit is contained in:
@@ -11,6 +11,7 @@ from _pytest import main
|
||||
from _pytest import outcomes
|
||||
from _pytest import reports
|
||||
from _pytest import runner
|
||||
from _pytest.outcomes import OutcomeException
|
||||
|
||||
|
||||
class TestSetupState:
|
||||
@@ -990,3 +991,18 @@ class TestReportContents:
|
||||
rep = reports[1]
|
||||
assert rep.capstdout == ""
|
||||
assert rep.capstderr == ""
|
||||
|
||||
|
||||
def test_outcome_exception_bad_msg():
|
||||
"""Check that OutcomeExceptions validate their input to prevent confusing errors (#5578)"""
|
||||
|
||||
def func():
|
||||
pass
|
||||
|
||||
expected = (
|
||||
"OutcomeException expected string as 'msg' parameter, got 'function' instead.\n"
|
||||
"Perhaps you meant to use a mark?"
|
||||
)
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
OutcomeException(func)
|
||||
assert str(excinfo.value) == expected
|
||||
|
||||
@@ -1066,7 +1066,8 @@ def test_module_level_skip_error(testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@pytest.skip
|
||||
pytest.skip("skip_module_level")
|
||||
|
||||
def test_func():
|
||||
assert True
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user