forked from TrueCloudLab/frostfs-testlib
[#133] Change reporter usage
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
39a17f3634
commit
dc6b0e407f
37 changed files with 478 additions and 678 deletions
|
@ -1,3 +1,5 @@
|
|||
from typing import Any
|
||||
|
||||
from frostfs_testlib.reporter.allure_handler import AllureHandler
|
||||
from frostfs_testlib.reporter.interfaces import ReporterHandler
|
||||
from frostfs_testlib.reporter.reporter import Reporter
|
||||
|
@ -20,3 +22,7 @@ def get_reporter() -> Reporter:
|
|||
|
||||
def step(title: str):
|
||||
return __reporter.step(title)
|
||||
|
||||
|
||||
def attach(content: Any, file_name: str):
|
||||
return __reporter.attach(content, file_name)
|
||||
|
|
|
@ -21,9 +21,14 @@ class AllureHandler(ReporterHandler):
|
|||
|
||||
def attach(self, body: Any, file_name: str) -> None:
|
||||
attachment_name, extension = os.path.splitext(file_name)
|
||||
if extension.startswith("."):
|
||||
extension = extension[1:]
|
||||
attachment_type = self._resolve_attachment_type(extension)
|
||||
|
||||
allure.attach(body, attachment_name, attachment_type, extension)
|
||||
if os.path.exists(body):
|
||||
allure.attach.file(body, file_name, attachment_type, extension)
|
||||
else:
|
||||
allure.attach(body, attachment_name, attachment_type, extension)
|
||||
|
||||
def _resolve_attachment_type(self, extension: str) -> attachment_type:
|
||||
"""Try to find matching Allure attachment type by extension.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue