Я использую ожидание pytest для выполнения мягкого утверждения или отложенного утверждения.
Таким образом, когда тесты выполняются, тест сообщается как неудачный в сообщении об очаровании, хотя шаг, на котором он провалился, не отображается в отчете об очаровании.
Я использую allure-pytest, чтобы сообщать о своих тестах при интеграционном тестировании с использованием селена.
Есть ли способ установить статус шага?
Я хотел создать функцию stop_step в allure-python, но она не сработала. Возможно я использую это неправильно!
Я думал об использовании его в качестве регистрации Python и шаг, чтобы потерпеть неудачу, когда record.levelname.lower () == 'error'.
Ниже приведено содержание conftest.py:
class AllureLoggingHandler(logging.Handler):
def log(self, message):
with allure.step('Log {}'.format(message)):
pass
def emit(self, record):
if record.levelname.lower() == 'error':
@allure_commons.hookimpl(hookwrapper=True)
def stop_step(self, uuid):
self.allure_logger.stop_step(uuid,
status=Status.FAILED)
self.log("({}) -> {}".format(record.levelname,record.getMessage()))
class AllureCatchLogs:
def __init__(self):
self.rootlogger = logging.getLogger()
self.allurehandler = AllureLoggingHandler()
def __enter__(self):
if self.allurehandler not in self.rootlogger.handlers:
self.rootlogger.addHandler(self.allurehandler)
def __exit__(self, exc_type, exc_value, traceback):
self.rootlogger.removeHandler(self.allurehandler)
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_setup():
with AllureCatchLogs():
yield
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call():
with AllureCatchLogs():
yield
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_teardown():
with AllureCatchLogs():
yield
---contents of my test_something.py
with allure.step('Checking user count.'):
expect(num_of_users == 0, 'some message fr expect')
num_of_users = 1
with allure.step('Checking user count._ 12'):
logging.info("checking 2nd step run")
Для этого я ожидал, что шаг: with allure.step ('Проверка количества пользователей.): Потерпеть неудачу, но он показался зеленым.