From e1f8c854f53825fbcda48518e99fbf245fe1d6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Sat, 16 Sep 2023 16:10:27 +0200 Subject: [PATCH] Ignore Kernel died in examples --- examples/conftest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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