allure-python
allure-python copied to clipboard
Limit step parameter content size in allure report
I'm submitting a ...
- [ ] bug report
- [x] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
Given following example
import allure
def test_example():
big_arg = 'abcdef ' * 1000
example_step(big_arg)
@allure.step("Example Step")
def example_step(big_arg):
pass
In allure report for above test for example_step
step argument big_arg
value is conveniently included in report. Even if value is quite large.
If the current behaviour is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
What is the expected behaviour?
What is the motivation / use case for changing the behaviour?
There are valid cases where argument(s) passed to allure.step
function is quite large and in my opinion it does not make sense to include all of it allure report. Perhaps instead it could be truncated to some reasonable length?
In case user wants to keep all contents of specific variables/arguments he or she can always use attachment feature.
In some cases where allure step functions are dealing with quite large text chunks this increases allure report size considerably. For now as a workaround I have to avoid using @allure.step
decorator and instead use with allure.step()
context manager inside step function.
Please tell us about your environment:
- Allure version: 2.7.0
- Test framework: [email protected]
- Allure adaptor: [email protected]
Other information
Tried this dirty patch of allure-pytest/src/listener.py:AllureListener
@allure_commons.hookimpl
def start_step(self, uuid, title, params):
def truncate(x):
if len(x) > 200:
return x[:180] + " ... " + x[-15:]
return x
parameters = [Parameter(name=name, value=truncate(value)) for name, value in params.items()]
step = TestStepResult(name=title, start=now(), parameters=parameters)
self.allure_logger.start_step(None, uuid, step)
Probably need some advice what to improve for proper PR?