2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Handle missing test_results due to pytest runner interrupt

If pytest execution is interrupted, the hook that exposes test_results
to the pytest session is never called so the results can't be
interpreted.
This commit is contained in:
Tom Krizek 2023-03-22 15:52:05 +01:00
parent 1cc55d01c7
commit 0a063f51d3
No known key found for this signature in database
GPG Key ID: 01623B9B652A20A7

View File

@ -316,10 +316,17 @@ if os.getenv("LEGACY_TEST_RUNNER", "0") == "0":
def get_test_result():
"""Aggregate test results from all individual tests from this module
into a single result: failed > skipped > passed."""
try:
all_test_results = request.session.test_results
except AttributeError:
# This may happen if pytest execution is interrupted and
# pytest_runtest_makereport() is never called.
logger.debug("can't obtain test results, test run was interrupted")
return "error"
test_results = {
node.nodeid: request.session.test_results[node.nodeid]
node.nodeid: all_test_results[node.nodeid]
for node in request.node.collect()
if node.nodeid in request.session.test_results
if node.nodeid in all_test_results
}
logger.debug(test_results)
assert len(test_results)