Missing unsafe keyword on unittest.mock.patch, unittest.mock.patch.object, and create_autospec
Đang mở
Chưa có ai nhận issue này.
docs
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Documentation
Unsafe keyword missing for both unittest.mock.patch and unittest.mock.patch.object
Current docs:
.. function:: patch(target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
.. function:: patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
Implementation
def patch(
target, new=DEFAULT, spec=None, create=False,
spec_set=None, autospec=None, new_callable=None, *, unsafe=False, **kwargs
):
def _patch_object(
target, attribute, new=DEFAULT, spec=None,
create=False, spec_set=None, autospec=None,
new_callable=None, *, unsafe=False, **kwargs
):
In fact, it's already there in patch docstring, just not in the docs for some reason:
Patch will raise a `RuntimeError` if passed some common misspellings of
the arguments autospec and spec_set. Pass the argument `unsafe` with the
value True to disable that check.
Linked PRs
- gh-136208
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ các mục tài liệu của unittest.mock dành cho patch và patch.object, rồi so sánh các signature được hiển thị với các signature của phần triển khai được nêu trong issue. Cập nhật tài liệu để hiển thị từ khóa unsafe cho patch, patch.object và create_autospec, sau đó xác minh rằng các signature được kết xuất và phần giải thích xung quanh khớp với docstring hiện có.
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
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100