Skip to content

Commit

Permalink
Fix test suite for Matplotlib 3.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Sep 17, 2023
1 parent 07d4456 commit 7b92f8e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion examples/circle_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def generate(X, Y, phi):
for i, phi in enumerate(np.linspace(0, 180. / np.pi, 100)):
if not Gcf.get_num_fig_managers():
break
ax.lines.clear()
for line in [*ax.lines]:
line.remove()
Z = generate(X, Y, phi)
ax.plot(X.flat, Z.flat, "ok")
plt.pause(.001)
Expand Down
3 changes: 2 additions & 1 deletion examples/square_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def generate(X, Y, phi):
for i, phi in enumerate(np.linspace(0, 180. / np.pi, 100)):
if not Gcf.get_num_fig_managers():
break
ax.lines.clear()
for line in [*ax.lines]:
line.remove()
Z = generate(X, Y, phi)
ax.plot(X.flat, Z.flat, "sk")
plt.pause(.001)
Expand Down
5 changes: 5 additions & 0 deletions run-mpl-test-suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def pytest_collection_modifyitems(session, config, items):
"test_backend_pdf.py::test_savefig_metadata",
# cairo doesn't emit HiResBoundingBox.
"test_backend_ps.py::test_bbox",
# Different tight bbox.
"test_backend_ps.py::test_colorbar_shift[",
# cairo doesn't support setting fonttype.
"test_backend_ps.py::test_fonttype[",
# We're fine with partial usetex.
Expand All @@ -174,6 +176,7 @@ def pytest_collection_modifyitems(session, config, items):
# skips emitting clips that don't intersect paths).
"test_backend_svg.py::test_count_bitmaps",
# cairo doesn't support custom gids or metadata.
"test_backend_svg.py::test_annotationbbox_gid",
"test_backend_svg.py::test_gid",
"test_backend_svg.py::test_svg_clear_all_metadata",
"test_backend_svg.py::test_svg_clear_default_metadata",
Expand All @@ -195,6 +198,8 @@ def pytest_collection_modifyitems(session, config, items):
# cairo uses a different representation for ps images (but
# compositing is correct, see e.g. SVG output).
"test_image.py::test_composite[",
# Different legend positioning.
"test_legend.py::test_figure_legend_outside",
# Different tight bbox.
"test_polar.py::test_get_tightbbox_polar",
# cairo does not have an explicit rendering complexity limit.
Expand Down
17 changes: 9 additions & 8 deletions tools/ensure-mpl-test-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# Ensure that the current Matplotlib install includes test data.

import importlib
from pathlib import Path
import shutil
from tempfile import TemporaryDirectory
import urllib.request

import matplotlib as mpl
import mpl_toolkits


try:
Expand All @@ -22,12 +22,13 @@
Path(tmpdir, "matplotlib.tar.gz").open("wb") as file:
file.write(request.read())
shutil.unpack_archive(file.name, tmpdir)
for pkg in [mpl, mpl_toolkits]:
shutil.rmtree(
Path(list(pkg.__path__)[0], "tests"), ignore_errors=True)
shutil.move(
str(Path(tmpdir, f"matplotlib-{mpl.__version__}",
"lib", pkg.__name__, "tests")), # bpo#32689 (Py<3.9).
list(pkg.__path__)[0])
libdir = Path(tmpdir, f"matplotlib-{mpl.__version__}", "lib")
for testdir in libdir.glob("**/tests"):
pkgdir = testdir.relative_to(libdir).parent # Drop "tests".
pkgpath = list(
importlib.import_module(pkgdir.as_posix().replace("/", "."))
.__path__)[0]
shutil.rmtree(Path(pkgpath, "tests"), ignore_errors=True)
shutil.move(str(testdir), pkgpath) # bpo#32689 (Py<3.9).
else:
print("Matplotlib test data already present.")

0 comments on commit 7b92f8e

Please sign in to comment.