Generalize pytest-mpl to support non-Matplotlib visual output
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- jupyter, playwright, python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với entry point pytest.mark.mpl_image_compare hiện có và bài kiểm thử ví dụ trong issue, sau đó theo dõi cách các figure Matplotlib được trả về được chuyển đổi để tạo hash và gallery. Xác định đường dẫn giá trị trả về không dùng Matplotlib được hỗ trợ, bao gồm PIL.Image, và xác minh rằng việc so sánh hình ảnh, hash và gallery vẫn hoạt động mà không cần wrapper Matplotlib.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I am currently trying to use the Solara testing framework to try and do unit/regression testing of the rendering of Jupyter widgets, and I was wishing that I could just re-use all the pytest-mpl infrastructure to do figure hashes, galleries, etc. In a discussion with @Cadair we realised that it is possible, although a little ugly right now:
import ipywidgets as widgets
import matplotlib.pyplot as plt
import playwright.sync_api
import pytest
from IPython.display import display
from PIL import Image
@pytest.mark.mpl_image_compare(savefig_kwargs={"dpi": 100})
def test_scatter_solara(
tmp_path,
solara_test,
page_session: playwright.sync_api.Page,
assert_solara_snapshot,
):
from glue_jupyter import jglue
from IPython.display import display
app = jglue()
app.add_data(a={"x": [1, 2, 3], "y": [2, 3, 4]})
scatter = app.scatter2d(show=False)
display(scatter._layout)
button_sel = page_session.locator("text=No selection")
button_sel.wait_for()
screenshot = page_session.screenshot()
with open(tmp_path / "screenshot.png", "wb") as f:
f.write(screenshot)
image = Image.open(tmp_path / "screenshot.png")
size_x, size_y = image.size
fig = plt.figure(figsize=(size_x / 100, size_y / 100))
ax = fig.add_axes([0, 0, 1, 1])
ax.imshow(image)
plt.axis("off")
return fig
Basically one can in principle take any image output and show it in a Matplotlib figure. However this is a bit hacky, and what would be a lot nicer would be if we could generalize this plugin to allow for alternatives to what actually generates the images, with Matplotlib being just one (and given the plugin name the default) option.
To keep this simple, we could also simply allow the returned value from tests to be a PIL Image instance as this would already allow any arbitrary image generation in the tests.
Does anyone have any thoughts on this? Any reason to not at least allow PIL returns?
- Ngôn ngữ chính
- Python
- Star
- 274
- Fork
- 53
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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.
Issue khác của matplotlib/pytest-mpl
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
matplotlib/pytest-mpl#264 · 2 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
matplotlib/pytest-mpl#263 · 3 bình luận ·
-
Old docs on matplotlib.orgĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
matplotlib/pytest-mpl#262 · 6 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
matplotlib/pytest-mpl#261 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
matplotlib/pytest-mpl#257 · 2 bình luận ·
Tất cả issue của matplotlib/pytest-mpl
Issue tương tự
-
[Doc]: Feedback for `/zh-cn/v0.30.0/tutorials/models/Qwen3.6-35B-A3B.html`A3社区配置和基线不一致,社区配置也达不到基线Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
vllm-project/vllm-ascend#24429 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
simnJS/AnyPS5#735 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sqlreview.sh: `remap` with no review draft seeds one, and `delta` prints the diff then exits 2Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
nq-rdl/agent-extensions#623 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vortex-data/vortex#12633 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
gke-labs/kube-agents#7955 ·
Maintainer thường phản hồi trong vòng 1 ngày