Skip to content

Commit 4381df5

Browse files
authored
Add example conftest (#150)
1 parent 3565943 commit 4381df5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def pytest_runtest_makereport(item, call):
2+
"""
3+
Skip tests that fail because "the kernel died before replying to kernel_info"
4+
this is a common error when running the example tests in CI.
5+
6+
Inspired from: https://stackoverflow.com/questions/32451811
7+
8+
"""
9+
from _pytest.runner import pytest_runtest_makereport
10+
11+
tr = pytest_runtest_makereport(item, call)
12+
13+
if call.excinfo is not None:
14+
msgs = [
15+
"Kernel died before replying to kernel_info",
16+
"Kernel didn't respond in 60 seconds",
17+
]
18+
for msg in msgs:
19+
if call.excinfo.type is RuntimeError and call.excinfo.value.args[0] in msg:
20+
tr.outcome = "skipped"
21+
tr.wasxfail = f"reason: {msg}"
22+
23+
return tr

0 commit comments

Comments
 (0)