Skip to content

Commit 27a1aaa

Browse files
committed
Fix issue where pytest_runtest_makereport was hiding exceptions from other plugins
Fix #98
1 parent d242cfd commit 27a1aaa

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.7.1.dev #
2+
3+
- Fixed internal error when interacting with other plugins that raise an error,
4+
hiding the original exception (#98). Thanks @The-Compiler for the PR!
5+
6+
- Now `pytest-qt` is properly tested with PyQt5 on Travis-CI. Many thanks
7+
to @The-Compiler for the PR!
8+
19
# 1.7.0 #
210

311
- `PYTEST_QT_API` can now be set to `pyqt4v2` in order to use version 2 of the

pytestqt/logging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ def pytest_runtest_setup(self, item):
4040
@pytest.mark.hookwrapper
4141
def pytest_runtest_makereport(self, item, call):
4242
"""Add captured Qt messages to test item report if the call failed."""
43-
4443
outcome = yield
4544
if not hasattr(item, 'qt_log_capture'):
4645
return
4746

4847
if call.when == 'call':
49-
report = outcome.result
48+
report = outcome.get_result()
5049

5150
m = item.get_marker('qt_log_level_fail')
5251
if m:

tests/test_logging.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,32 @@ def test_foo(request):
484484
'*None:None:None:*',
485485
'* QtWarningMsg: WARNING message*',
486486
])
487+
488+
489+
def test_logging_broken_makereport(testdir):
490+
"""
491+
Make sure logging's makereport hookwrapper doesn't hide exceptions.
492+
493+
See https://github.com/pytest-dev/pytest-qt/issues/98
494+
495+
:type testdir: _pytest.pytester.TmpTestdir
496+
"""
497+
testdir.makepyfile(conftest="""
498+
import pytest
499+
500+
@pytest.mark.hookwrapper(tryfirst=True)
501+
def pytest_runtest_makereport(call):
502+
if call.when == 'call':
503+
raise Exception("This should not be hidden")
504+
yield
505+
""")
506+
p = testdir.makepyfile(
507+
"""
508+
def test_foo():
509+
pass
510+
"""
511+
)
512+
res = testdir.runpytest_subprocess(p)
513+
res.stdout.fnmatch_lines([
514+
'*This should not be hidden*',
515+
])

0 commit comments

Comments
 (0)