allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
730 stars 237 forks source link

Improve context manager #826

Open danielhoherd opened 2 months ago

danielhoherd commented 2 months ago

I'm submitting a ...

What is the current behavior?

Context manager for allure.step() does not allow assigning a variable name, which would be useful.

What is the expected behavior?

I'd like it if this worked:

with allure.step('foo') as s:
    print(s.title)

I expected that to work because this does work:

s = allure.step('foo')
print(s.title)

What is the motivation / use case for changing the behavior?

Having this named context manager would keep very simple code DRY.

Please tell us about your environment: