File tree 4 files changed +23
-2
lines changed 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -96,3 +96,4 @@ Tom Viner
96
96
Trevor Bekolay
97
97
Wouter van Ackooy
98
98
Bernard Pratz
99
+ Jon Sonesen
Original file line number Diff line number Diff line change 31
31
deprecated but still present. Thanks to `@RedBeardCode `_ and `@tomviner `_
32
32
for PR (`#1626 `_).
33
33
34
- *
34
+ * Add stderr write for pytest.exit(msg) calls. Previously the message was never shown.
35
+ Thanks `@BeyondEvil `_ for reporting `#1210 `_. Thanks to `@JonathonSonesen `_ and
36
+ `@tomviner `_ for PR.
35
37
38
+ *
36
39
.. _#1580 : https://github.com/pytest-dev/pytest/pull/1580
37
40
.. _#1605 : https://github.com/pytest-dev/pytest/issues/1605
38
41
.. _#1597 : https://github.com/pytest-dev/pytest/pull/1597
39
42
.. _#460 : https://github.com/pytest-dev/pytest/pull/460
40
43
.. _#1553 : https://github.com/pytest-dev/pytest/issues/1553
41
44
.. _#1626 : https://github.com/pytest-dev/pytest/pull/1626
45
+ .. _#1210 : https://github.com/pytest-dev/pytest/issues/1210
42
46
43
47
.. _@graingert : https://github.com/graingert
44
48
.. _@taschini : https://github.com/taschini
45
49
.. _@nikratio : https://github.com/nikratio
46
50
.. _@RedBeardCode : https://github.com/RedBeardCode
47
51
.. _@Vogtinator : https://github.com/Vogtinator
52
+ .. _@BeyondEvil : https://github.com/BeyondEvil
53
+ .. _@JonathonSonesen : https://github.com/JonathonSonesen
48
54
49
55
50
56
2.9.2
Original file line number Diff line number Diff line change @@ -90,10 +90,12 @@ def wrap_session(config, doit):
90
90
session .exitstatus = doit (config , session ) or 0
91
91
except pytest .UsageError :
92
92
raise
93
- except KeyboardInterrupt :
93
+ except KeyboardInterrupt as e :
94
94
excinfo = _pytest ._code .ExceptionInfo ()
95
95
config .hook .pytest_keyboard_interrupt (excinfo = excinfo )
96
96
session .exitstatus = EXIT_INTERRUPTED
97
+ except pytest .Exit as e :
98
+ sys .stderr .write ('{0}: {1}\n ' .format (type (e ).__name__ , e .msg ))
97
99
except :
98
100
excinfo = _pytest ._code .ExceptionInfo ()
99
101
config .notify_exception (excinfo , config .option )
Original file line number Diff line number Diff line change @@ -457,6 +457,18 @@ def test_pytest_fail():
457
457
s = excinfo .exconly (tryshort = True )
458
458
assert s .startswith ("Failed" )
459
459
460
+ def test_pytest_exit_msg (testdir ):
461
+ testdir .makeconftest ("""
462
+ import pytest
463
+
464
+ def pytest_configure(config):
465
+ pytest.exit('oh noes')
466
+ """ )
467
+ result = testdir .runpytest ()
468
+ result .stderr .fnmatch_lines ([
469
+ "Exit: oh noes" ,
470
+ ])
471
+
460
472
def test_pytest_fail_notrace (testdir ):
461
473
testdir .makepyfile ("""
462
474
import pytest
You can’t perform that action at this time.
0 commit comments