tests: add soft assertion
This commit is contained in:
parent
a7cb7376dd
commit
c2b0a1c7d1
|
@ -1,13 +1,13 @@
|
||||||
import logging
|
import logging
|
||||||
|
import configs
|
||||||
import os
|
import os
|
||||||
import allure
|
import allure
|
||||||
import pytest
|
import pytest
|
||||||
import shortuuid
|
|
||||||
from PIL import ImageGrab
|
|
||||||
|
|
||||||
import configs
|
from tests import test_data
|
||||||
from configs.system import get_platform
|
from PIL import ImageGrab
|
||||||
|
from datetime import datetime
|
||||||
|
from configs.system import IS_LIN
|
||||||
from fixtures.path import generate_test_info
|
from fixtures.path import generate_test_info
|
||||||
from scripts.utils.system_path import SystemPath
|
from scripts.utils.system_path import SystemPath
|
||||||
|
|
||||||
|
@ -52,12 +52,31 @@ def setup_function_scope(
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_runtest_setup(item):
|
||||||
|
test_data.test_name = item.name
|
||||||
|
|
||||||
|
test_data.error = []
|
||||||
|
test_data.steps = []
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||||
def pytest_runtest_makereport(item, call):
|
def pytest_runtest_makereport(item, call):
|
||||||
outcome = yield
|
outcome = yield
|
||||||
rep = outcome.get_result()
|
rep = outcome.get_result()
|
||||||
setattr(item, 'rep_' + rep.when, rep)
|
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):
|
def pytest_exception_interact(node):
|
||||||
test_path, test_name, test_params = generate_test_info(node)
|
test_path, test_name, test_params = generate_test_info(node)
|
||||||
|
|
|
@ -287,10 +287,6 @@ class LeftPanel(QObject):
|
||||||
def is_add_channels_button_visible(self) -> bool:
|
def is_add_channels_button_visible(self) -> bool:
|
||||||
return self._add_channels_button.is_visible
|
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')
|
@allure.step('Select channel')
|
||||||
def select_channel(self, name: str):
|
def select_channel(self, name: str):
|
||||||
for obj in driver.findAllObjects(self._channel_list_item.real_name):
|
for obj in driver.findAllObjects(self._channel_list_item.real_name):
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class TestData:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
self.test_name = None
|
||||||
|
self.steps = []
|
||||||
|
self.error = []
|
||||||
|
|
||||||
|
|
||||||
|
test_data = TestData()
|
|
@ -1,9 +1,10 @@
|
||||||
import allure
|
import allure
|
||||||
import pytest
|
import pytest
|
||||||
from allure_commons._allure import step
|
|
||||||
|
|
||||||
import configs
|
import configs
|
||||||
import constants
|
import constants
|
||||||
|
|
||||||
|
from allure_commons._allure import step
|
||||||
|
from tests import test_data
|
||||||
from gui.components.context_menu import ContextMenu
|
from gui.components.context_menu import ContextMenu
|
||||||
from gui.main_window import MainWindow
|
from gui.main_window import MainWindow
|
||||||
from . import marks
|
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')
|
community_screen = main_screen.left_panel.select_community('Community with 2 users')
|
||||||
|
|
||||||
with step('Verify that member cannot add category'):
|
with step('Verify that member cannot add category'):
|
||||||
with step('Verify that create channel or category button is not present'):
|
if community_screen.left_panel._channel_or_category_button.exists:
|
||||||
assert not community_screen.left_panel.does_create_channel_or_category_button_exist()
|
test_data.error.append("Create channel or category button is present")
|
||||||
with step('Verify that add category button is not present'):
|
if community_screen.left_panel._create_category_button.is_visible:
|
||||||
assert not community_screen.left_panel.is_add_category_button_visible()
|
test_data.error.append("Create category button is visible")
|
||||||
|
|
||||||
with step('Verify that member cannot edit category'):
|
with step('Verify that member cannot edit category'):
|
||||||
with step('Right-click on category in the left navigation bar'):
|
with step('Right-click on category in the left navigation bar'):
|
||||||
|
|
Loading…
Reference in New Issue