Allure step placeholder fails when accessing dataclass attribute `data.name`

Open
#896 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
testing

Research direction

Start with the usage in step_placeholder.rst and reproduce the failure using the dataclass example with Python 3.12 and allure-pytest 2.15.2. Trace the step-title placeholder rendering and add coverage for dataclass attribute access; done means the step displays the resolved name without raising AttributeError.

Written by the indexing model from the issue text.

Description

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
  • data is 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?

Dominant language
Python
Stars
815
Forks
260
Avg merge
9h 12m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from allure-framework/allure-python

All issues in allure-framework/allure-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.