From c2b0a1c7d14b53566e297b25a34bd4222274a3c6 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 13 Aug 2024 12:31:45 +0200 Subject: [PATCH] tests: add soft assertion --- test/e2e/conftest.py | 29 +++++++++++++++---- test/e2e/gui/screens/community.py | 4 --- test/e2e/tests/__init__.py | 10 +++++++ .../test_communities_categories.py | 13 +++++---- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index f7196ea301..1ccb94abf7 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -1,13 +1,13 @@ import logging - +import configs import os import allure import pytest -import shortuuid -from PIL import ImageGrab -import configs -from configs.system import get_platform +from tests import test_data +from PIL import ImageGrab +from datetime import datetime +from configs.system import IS_LIN from fixtures.path import generate_test_info from scripts.utils.system_path import SystemPath @@ -52,12 +52,31 @@ def setup_function_scope( yield +def pytest_runtest_setup(item): + test_data.test_name = item.name + + test_data.error = [] + test_data.steps = [] + @pytest.hookimpl(tryfirst=True, hookwrapper=True) def pytest_runtest_makereport(item, call): outcome = yield rep = outcome.get_result() setattr(item, 'rep_' + rep.when, rep) + if rep.when == 'call': + if rep.failed: + test_data.error = rep.longreprtext + elif rep.outcome == 'passed': + if test_data.error: + rep.outcome = 'failed' + error_text = str() + for line in test_data.error: + error_text += f"{line}; \n ---- soft assert ---- \n\n" + rep.longrepr = error_text + elif rep.failed: + test_data.error = rep.longreprtext + def pytest_exception_interact(node): test_path, test_name, test_params = generate_test_info(node) diff --git a/test/e2e/gui/screens/community.py b/test/e2e/gui/screens/community.py index 2881146f04..eb12ffcf4b 100644 --- a/test/e2e/gui/screens/community.py +++ b/test/e2e/gui/screens/community.py @@ -287,10 +287,6 @@ class LeftPanel(QObject): def is_add_channels_button_visible(self) -> bool: return self._add_channels_button.is_visible - @allure.step('Get visibility state of add category button') - def is_add_category_button_visible(self) -> bool: - return self._create_category_button.is_visible - @allure.step('Select channel') def select_channel(self, name: str): for obj in driver.findAllObjects(self._channel_list_item.real_name): diff --git a/test/e2e/tests/__init__.py b/test/e2e/tests/__init__.py index e69de29bb2..b7824724b2 100644 --- a/test/e2e/tests/__init__.py +++ b/test/e2e/tests/__init__.py @@ -0,0 +1,10 @@ +class TestData: + + def __init__(self): + + self.test_name = None + self.steps = [] + self.error = [] + + +test_data = TestData() diff --git a/test/e2e/tests/communities/test_communities_categories.py b/test/e2e/tests/communities/test_communities_categories.py index cc0c875576..b17b011ab4 100644 --- a/test/e2e/tests/communities/test_communities_categories.py +++ b/test/e2e/tests/communities/test_communities_categories.py @@ -1,9 +1,10 @@ import allure import pytest -from allure_commons._allure import step - import configs import constants + +from allure_commons._allure import step +from tests import test_data from gui.components.context_menu import ContextMenu from gui.main_window import MainWindow from . import marks @@ -25,10 +26,10 @@ def test_member_role_cannot_add_edit_or_delete_category(main_screen: MainWindow) community_screen = main_screen.left_panel.select_community('Community with 2 users') with step('Verify that member cannot add category'): - with step('Verify that create channel or category button is not present'): - assert not community_screen.left_panel.does_create_channel_or_category_button_exist() - with step('Verify that add category button is not present'): - assert not community_screen.left_panel.is_add_category_button_visible() + if community_screen.left_panel._channel_or_category_button.exists: + test_data.error.append("Create channel or category button is present") + if community_screen.left_panel._create_category_button.is_visible: + test_data.error.append("Create category button is visible") with step('Verify that member cannot edit category'): with step('Right-click on category in the left navigation bar'):