Commit 8d150518 authored by norvell's avatar norvell
Browse files

Add hook to catch exceptions in test_info.error to trigger pytest errors

parent 6c9ddc40
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -446,6 +446,17 @@ def test_info(request):
    if hasattr(request, "error"):
    if hasattr(request, "error"):
        pytest.fail(request.error)
        pytest.fail(request.error)


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    # Use hook to catch exceptions
    outcome = yield
    report = outcome.get_result()
    test_info = item.funcargs.get("test_info", None)

    if call.excinfo is not None and report.when == "call":
        # Capture exception in test_info
        test_info.error = str(call.excinfo.value)



@pytest.fixture(scope="session")
@pytest.fixture(scope="session")
def split_comparison(request):
def split_comparison(request):