diff --git a/examples/conftest.py b/examples/conftest.py index 5617e8ba05..337665f9ed 100644 --- a/examples/conftest.py +++ b/examples/conftest.py @@ -38,3 +38,23 @@ "gallery/demos/*/bachelors_degrees_by_gender.ipynb", "gallery/demos/*/topographic_hillshading.ipynb", ] + + +def pytest_runtest_makereport(item, call): + """ + Skip tests that fail because the kernel died before replying to kernel_info + this is a common error when running the example tests + + Inspired from: https://stackoverflow.com/questions/32451811 + + """ + from _pytest.runner import pytest_runtest_makereport + tr = pytest_runtest_makereport(item, call) + + if call.excinfo is not None: + msg = "Kernel died before replying to kernel_info" + if call.excinfo.type == RuntimeError and call.excinfo.value.args[0] == msg: + tr.outcome = 'skipped' + tr.wasxfail = f"reason: {msg}" + + return tr