Пользовательские метки Allure не будут отображаться в итоговом отчете (pytest, allure).Python

Программы на Python
Anonymous
Пользовательские метки Allure не будут отображаться в итоговом отчете (pytest, allure).

Сообщение Anonymous »


[*]python 3.12.2

[*]allure-pytest: 2.13.5

[*]allure-python-commons: 2.13.5

[*]pytest : 8.2.2

[*]allure CLI: 2.30.0


Предпосылка
В документации Allure указано, что я могу добавлять метки.

Код: Выделить всё

import allure from allure_commons.types
import LabelType

@allure.label(LabelType.LANGUAGE, "python")
@allure.label(LabelType.FRAMEWORK, "pytest")
def test_authentication():
"Это может быть константа из класса LabelType или любая другая строка".
Поэтому я предполагаю, что так и должно быть работа:

Код: Выделить всё

import allure

@allure.label("any other string", "python")
@allure.label("another any other string", "pytest")
def test_authentication():
Проблема
Однако, когда я добавляю свою собственную метку любую другую строку через @allure.label(), он не будет отображаться в отчете.
Например:

Код: Выделить всё

# root_dir/test.py

import allure

@allure.label('Area', 'someArea')
@allure.label('Component', 'someComponent')
@allure.label('Relevance', 'someVersion')
def test_smth()
Затем я запускаю тест; укажите report/, чтобы сохранить отчет; и откройте его в браузере:

Код: Выделить всё

pytest -v -s --alluredir reports

Код: Выделить всё

allure serve reports
И в отчете нет никаких следов моих пользовательских ярлыков. И нет соответствующего тега, элемента или чего-то еще в HTML отчета.
В то же время, когда я открываю *-result.json в моем каталоге отчетов Allure, report/ , я вижу там свои собственные метки:

Код: Выделить всё

"labels": [{"name": "Area", "value": "someArea"}, {"name": "Component", "value": "someComponent"}, {"name": "Relevance", "value": "someVersion"}
Кстати
Пример из документации не отображается в итоговом отчете:

Код: Выделить всё

@allure.label(LabelType.LANGUAGE, "python")
Что на самом деле отображается в итоговом отчете:

Код: Выделить всё

@allure.title()
@allure.description()
@allure.severity()
@allure.testcase()
@allure.story()
@allure.featur()
@allure.tag
Что еще я пробовал:
Создал отдельное место для хранения ярлыков

Код: Выделить всё

# root_dir/custom_allure_labels.py

import allure

def area(value):
return allure.label('Area', value)

def component(value):
return allure.label('Component', value)

def relevance(value):
return allure.label('Relevance', value)

Код: Выделить всё

# root_dir/test.py

import allure
from custom_allure_labels import area, component, relevance

@area('someArea')
@component('someComponent')
@relevance('someVersion')
def test_smth()
Нет результата.
Все то же самое + добавление свойств

Код: Выделить всё

# root_dir/allure.properties

allure.label.Area=Area
allure.label.Component=Component
allure.label.Relevance=Relevance

Код: Выделить всё

# root_dir/custom_allure_labels.py

import allure
from allure_commons.types import LabelType

def area(value):
allure.label(LabelType.CUSTOM_LABEL_1, value)
return allure.label('Area', value)
def component(value):
allure.label(LabelType.CUSTOM_LABEL_2, value)
return allure.label('Component', value)
def relevance(value):
allure.label(LabelType.CUSTOM_LABEL_3, value)
return allure.label('Relevance', value)

Код: Выделить всё

# root_dir/test.py

import allure
from custom_allure_labels import area, component, relevance

@area('someArea')
@component('someComponent')
@relevance('someVersion')
def test_smth()
Нет результата.
Аналогично, но добавлена ​​функция декоратора

Код: Выделить всё

# root_dir/custom_allure_labels.py

import allure

def custom_allure_labels(area, component, relevance):
def decorator(func):
allure.label('Area', area)(func)
allure.label('Component', component)(func)
allure.label('Relevance', relevance)(func)
return func
return decorator

Код: Выделить всё

# root_dir/test.py

import allure
from custom_allure_labels import area, component, relevance

@custom_allure_labels(
area='someArea',
component='someComponent',
relevance='someVersion',
)
def test_smth()
Вопрос
Что не так с тем, что я пытаюсь сделать?
Есть ли способ добавить пользовательские атрибуты в LabelType?

Подробнее здесь: https://stackoverflow.com/questions/788 ... est-allure

Вернуться в «Python»