summaryrefslogtreecommitdiff
path: root/testing/test_runner.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2019-07-08 20:33:43 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2019-07-09 18:26:57 -0300
commit9db182370770b24a4434af48375a63fed9905a93 (patch)
tree7818f7f179d0b330ecc98a1c9c3eb08a48063e9d /testing/test_runner.py
parent2180d9ef6d9af45c80fdc89cd64b90df2924c8a7 (diff)
downloadpytest-9db182370770b24a4434af48375a63fed9905a93.tar.gz
Improve type-checking in OutcomeException
Fix #5578
Diffstat (limited to 'testing/test_runner.py')
-rw-r--r--testing/test_runner.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/test_runner.py b/testing/test_runner.py
index 15180c071..82e413518 100644
--- a/testing/test_runner.py
+++ b/testing/test_runner.py
@@ -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