8000 Fix test suite for Matplotlib 3.7. · matplotlib/mplcairo@7b92f8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 7b92f8e

Browse files
committed
Fix test suite for Matplotlib 3.7.
1 parent 07d4456 commit 7b92f8e

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

examples/circle_markers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def generate(X, Y, phi):
2929
for i, phi in enumerate(np.linspace(0, 180. / np.pi, 100)):
3030
if not Gcf.get_num_fig_managers():
3131
break
32-
ax.lines.clear()
32+
for line in [*ax.lines]:
33+
line.remove()
3334
Z = generate(X, Y, phi)
3435
ax.plot(X.flat, Z.flat, "ok")
3536
plt.pause(.001)

examples/square_markers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def generate(X, Y, phi):
2929
for i, phi in enumerate(np.linspace(0, 180. / np.pi, 100)):
3030
if not Gcf.get_num_fig_managers():
3131
break
32-
ax.lines.clear()
32+
for line in [*ax.lines]:
33+
line.remove()
3334
Z = generate(X, Y, phi)
3435
ax.plot(X.flat, Z.flat, "sk")
3536
plt.pause(.001)

run-mpl-test-suite.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def pytest_collection_modifyitems(session, config, items):
157157
"test_backend_pdf.py::test_savefig_metadata",
158158
# cairo doesn't emit HiResBoundingBox.
159159
"test_backend_ps.py::test_bbox",
160+
# Different tight bbox.
161+
"test_backend_ps.py::test_colorbar_shift[",
160162
# cairo doesn't support setting fonttype.
161163
"test_backend_ps.py::test_fonttype[",
162164
# We're fine with partial usetex.
@@ -174,6 +176,7 @@ def pytest_collection_modifyitems(session, config, items):
174176
# skips emitting clips that don't intersect paths).
175177
"test_backend_svg.py::test_count_bitmaps",
176178
# cairo doesn't support custom gids or metadata.
179+
"test_backend_svg.py::test_annotationbbox_gid",
177180
"test_backend_svg.py::test_gid",
178181
"test_backend_svg.py::test_svg_clear_all_metadata",
179182
"test_backend_svg.py::test_svg_clear_default_metadata",
@@ -195,6 +198,8 @@ def pytest_collection_modifyitems(session, config, items):
195198
# cairo uses a different representation for ps images (but
196199
# compositing is correct, see e.g. SVG output).
197200
"test_image.py::test_composite[",
201+
# Different legend positioning.
202+
"test_legend.py::test_figure_legend_outside",
198203
# Different tight bbox.
199204
"test_polar.py::test_get_tightbbox_polar",
200205
# cairo does not have an explicit rendering complexity limit.

tools/ensure-mpl-test-data.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Ensure that the current Matplotlib install includes test data.
44

5+
import importlib
56
from pathlib import Path
67
import shutil
78
from tempfile import TemporaryDirectory
89
import urllib.request
910

1011
import matplotlib as mpl
11-
import mpl_toolkits
1212

1313

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

0 commit comments

Comments
 (0)
0