Generalize pytest-mpl to support non-Matplotlib visual output
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- jupyter, playwright, python
- Área
- testing-qa
Línea de trabajo
Comienza con el punto de entrada existente pytest.mark.mpl_image_compare y la prueba de ejemplo del issue; después, sigue cómo se convierten las figuras de Matplotlib devueltas para los hashes y las galerías. Define la ruta de retorno compatible que no use Matplotlib, incluido PIL.Image, y verifica que la comparación de imágenes, los hashes y las galerías sigan funcionando sin el wrapper de Matplotlib.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- Python
- Estrellas
- 274
- Forks
- 53
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de matplotlib/pytest-mpl
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
matplotlib/pytest-mpl#264 · 2 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
matplotlib/pytest-mpl#263 · 3 comentarios ·
-
Old docs on matplotlib.orgAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
matplotlib/pytest-mpl#262 · 6 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
matplotlib/pytest-mpl#261 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
matplotlib/pytest-mpl#257 · 2 comentarios ·
Todos los issues de matplotlib/pytest-mpl
Issues similares
-
[Doc]: Feedback for `/zh-cn/v0.30.0/tutorials/models/Qwen3.6-35B-A3B.html`A3社区配置和基线不一致,社区配置也达不到基线Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
vllm-project/vllm-ascend#24429 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
simnJS/AnyPS5#735 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
sqlreview.sh: `remap` with no review draft seeds one, and `delta` prints the diff then exits 2Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
nq-rdl/agent-extensions#623 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
vortex-data/vortex#12633 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
gke-labs/kube-agents#7955 ·
Los mantenedores suelen responder en 1 día