Allure step placeholder fails when accessing dataclass attribute `data.name`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza con el uso en step_placeholder.rst y reproduce el fallo usando el ejemplo de dataclass con Python 3.12 y allure-pytest 2.15.2. Sigue el renderizado del marcador de posición step-title y añade cobertura para el acceso a atributos de dataclass; se considera completado cuando el paso muestra el nombre resuelto sin generar AttributeError.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
With the usage provided in step_placeholder.rst, I used Allure step placeholders to reference a property on a Python dataclass passed as a function argument. Using data.name in the step title raises an AttributeError during step rendering.
Expected behavior
Allure should resolve data.name and display the value of the name attribute in the step title like Create opportunity: Auto QA Example
Actual behavior
Allure raises an exception before the step executes: AttributeError: 'str' object has no attribute 'get('name)'
MWE of dataclass used
@dataclass
class OpportunityData:
"""Data class for opportunity test data."""
name: str
expected_revenue: str
email: Optional[str] = None
phone: Optional[str] = None
state: Optional[str] = None
street: Optional[str] = None
zip_code: Optional[str] = None
Factory function for Opportunity creation
def create_opportunity_data() -> OpportunityData:
"""Factory function to create OpportunityData for tests."""
data = OpportunityData(
name=f"Auto QA {fake.company()}",
expected_revenue=_generate_expected_revenue(),
email = fake.email()
phone = fake.phone_number()
street = fake.street_address()
zip_code = fake.zipcode()
state=fake.random_element(STATE_OPTIONS),
)
return data
Test Opportunity file
@allure.title("Test opportunity creation with all main fields")
@allure.testcase("CRM-002")
@pytest.mark.regression
def test_opportunity_creation_full(opportunity_page: OpportunityPage, app_instance: App) -> None:
# ARRANGE
data = create_opportunity_data(full=True, opportunity_type="CRM Multi-Year")
# ACT
opportunity_page.create_opportunity(data)
# ASSERT
opportunity_page.verify_opportunity_saved(data.name)
Opportunity Page class
@allure.step("Create opportunity: {data.name}")
def create_opportunity(self, data: "OpportunityData", base_url: str) -> Self:
"""High-level method to create an opportunity with provided data."""
# Fill main form fields
self.fill_opportunity_name(data.name)
self.fill_expected_revenue(data.expected_revenue)
Call stack
app_instance = <src.app.App object at 0x7f9f3034f8c0>
@allure.title("Test opportunity creation with minimal fields")
@allure.testcase("CRM-001")
@pytest.mark.smoke
def test_opportunity_creation_flow(opportunity_page: OpportunityPage, app_instance: App) -> None:
# ARRANGE
data = create_opportunity_data(opportunity_type="Monitoring")
# ACT
> opportunity_page.create_opportunity(data, app_instance.base_url)
E AttributeError: 'str' object has no attribute 'get('name)'
Notes
datais a dataclass instance, not a dict.- Attribute access works inside the function body.
- The error occurs during Allure step title formatting.
Environment
- Python 3.12
- allure-pytest==2.15.2
- pytest==8.4.2
- pytest-playwright==0.7.2
- mypy==1.19.0
- mypy-extensions==1.1.0
Does allure step placeholders accept only strings?
- Lenguaje dominante
- Python
- Estrellas
- 815
- Forks
- 260
- Merge medio
- 9 h 12 min
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de allure-framework/allure-python
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
-
Added Categories Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
allure-framework/allure-python#918 · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
allure-framework/allure-python#903 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
Todos los issues de allure-framework/allure-python
Issues similares
-
triage/confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
apache/cloudstack#14222 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100