Attach app logs added (#129)

#123
This commit is contained in:
Vladimir Druzhinin 2023-10-04 10:54:13 +02:00 committed by GitHub
parent 12ff7e2340
commit d545829724
3 changed files with 15 additions and 3 deletions

View File

@ -1,2 +1,2 @@
AUT_PORT = 61500
MLT_AUT_PORT = 61600
MAX_INSTANCES = 3

View File

@ -34,7 +34,8 @@ def setup_session_scope(
def setup_function_scope(
caplog,
generate_test_data,
check_result
check_result,
application_logs
):
caplog.set_level(configs.LOG_LEVEL)
yield
@ -62,7 +63,9 @@ def pytest_exception_interact(node):
body=screenshot.read_bytes(),
attachment_type=allure.attachment_type.PNG)
driver.context.detach()
for port in [configs.squish.AUT_PORT, configs.squish.MLT_AUT_PORT]:
# The maximum count of multiple instances in tests now is 3
max_instances = configs.squish.MAX_INSTANCES
for port in range(configs.squish.AUT_PORT, configs.squish.AUT_PORT + (max_instances * 1000), 1000):
pid = local_system.find_process_by_port(port)
if pid is not None:
local_system.kill_process(pid, verify=True)

View File

@ -1,3 +1,4 @@
import allure
import pytest
import configs
@ -8,6 +9,14 @@ from gui.main_window import MainWindow
from scripts.utils import system_path
from scripts.utils.system_path import SystemPath
@pytest.fixture
def application_logs():
yield
for app_data in configs.testpath.STATUS_DATA.iterdir():
for log in (app_data / 'logs').iterdir():
allure.attach.file(log, name=str(log.name), attachment_type=allure.attachment_type.TEXT)
log.unlink()
@pytest.fixture
def user_data(request) -> system_path.SystemPath: