Repository navigation
Improve context manager #826
Description
Activity
- addedtask:new featureRequesting new capability or software featureRequesting new capability or software feature
on Apr 1, 2025 @delatrie I was going to open a PR to solve this but when I looked at the python code it looked auto-generated, and I wasn't sure that my changes would be valuable. If you can point me in the right direction I may be able to close this one out. This thing is still bugging me.
Implementations that I can think of is making a verbose mode for the allure context manager, having an environment variable that turns on verbosity, or exposing the step title as an object in the context manager.
Hi, @danielhoherd
Thanks for your willingness to contribute to allure-python.There is no generated code here (although some of it is quite old).
If I understand your feature request correctly, the implementation is just a matter of returning the value from
__enter__here:allure-python/allure-python-commons/src/allure_commons/_allure.py
Lines 188 to 189 in ab14314
def __enter__(self): plugin_manager.hook.start_step(uuid=self.uuid, title=self.title, params=self.params) That would be a backward-compatible change, so no feature flag is required.
I heard today that we are going to be moving away from allure, so priority for me to complete this work has disappeared. I still think it's worth doing though because I assume at least some other folks are running into the same issue, but I am not going to have time to do it.
It's fine with me if this issue is closed as "not planned"
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:
I expected that to work because this does work:
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: