allure-framework / allure-framework/allure-python
Implement Allure listeners
- Ngôn ngữ chính
- Python
- Star
- 814
- Fork
- 260
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Context
People often need to somehow post-process Allure results according to their needs. Examples would be:
- filtering data they don't want in the report (parameters/labels/fixtures)
- customizing the default names, existing parameters, etc
- sending the results somewhere on the fly
Many such requirements are user-specific, and there is no point in implementing them here. Often, it's not even possible because many such requirements contradict each other.
Instead, it would be reasonable to have an easy-to-use extension mechanism that users may utilize for their purposes.
### Existing solution
Currently, users can register custom plugins in `allure_commons.plugin_manager`. For example:
```python
from allure_commons import hookimpl
from allure_commons import plugin_manager
class MyListener:
@hookimpl(tryfirst=True)
def report_result(self, result):
# post-process the result here
...
def pytest_configure(config):
def cleanup():
name = plugin_manager.get_name(listener)
plugin_manager.unregister(name=name)
listener = MyListener()
plugin_manager.register(listener)
config.add_cleanup(cleanup)
```
While covering many cases, the solution has some drawbacks:
- Verbose API:
- `tryfirst` is necessary to make sure the hook implementation is called after the default logger's one.
- The cleanup needs to be added separately.
- Limited hook spec:
- No steps and fixtures post-processing (only at the test result level, which complicates the processing).
- Limited support for attachments post-processing.
- No hooks for pre-processing.
### Implementation
Lifecycle listeners can be implemented with [pluggy](https://pluggy.readthedocs.io/en/stable/) as a plugin manager + hook specs + user-friendly API on top of this. We already use pluggy to implement the Allure API, so it's just a matter of defining one or more hook specs, calling them via the existing `allure_commons.plugin_manager` or a separate one.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng việc xem xét allure_commons.plugin_manager hiện có và triển khai Allure API dựa trên pluggy. Xác định phạm vi và vòng đời của listener xoay quanh các hook specs và API hướng tới người dùng được mô tả ở đây; công việc được xem là hoàn thành khi người dùng có thể đăng ký listener mà không cần sắp xếp thứ tự hoặc dọn dẹp thủ công, đồng thời có thể xử lý kết quả, step, fixture và tệp đính kèm trước hoặc sau quá trình xử lý.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- testing, tooling
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100