Files
scylladb/test/pylib/report_plugin.py
Andrei Chekun d0e4045103 test.py: add repeats in pytest
Previous way of executin repeat was to launch pytest for each repeat.
That was resource consuming, since each time pytest was doing discovery
of the tests. Now all repeats are done inside one pytest process.
2025-07-30 12:03:08 +02:00

34 lines
1.2 KiB
Python

#
# Copyright (C) 2024-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
import allure
import pytest
from allure_commons.model2 import Status
from allure_pytest.utils import get_pytest_report_status
class ReportPlugin:
config = None
# Pytest hook to attach logs to the Allure report only when the test fails.
def pytest_configure(self, config):
self.config = config
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(self):
outcome = yield
report = outcome.get_result()
status = get_pytest_report_status(report)
# skip attaching logs for passed tests
# attach_capture is a destination for "--allure-no-capture" option from allure-plugin
if status != Status.PASSED and not self.config.option.attach_capture:
if report.caplog:
allure.attach(report.caplog, "log", allure.attachment_type.TEXT, None)
if report.capstdout:
allure.attach(report.capstdout, "stdout", allure.attachment_type.TEXT, None)
if report.capstderr:
allure.attach(report.capstderr, "stderr", allure.attachment_type.TEXT, None)