Blob Blame History Raw
From d2a95cad1f605c45d55d4a8aa64a546d2b96c93f Mon Sep 17 00:00:00 2001
From: Antony Lee <anntzer.lee@gmail.com>
Date: Sat, 27 Jun 2020 23:30:27 +0200
Subject: [PATCH] Fixes for Matplotlib 3.3rc1 test suite.

---
 ISSUES.rst            | 11 ++++++++++-
 README.rst            |  4 ++--
 azure-pipelines.yml   |  2 +-
 lib/mplcairo/base.py  |  5 ++++-
 run-mpl-test-suite.py |  9 +++++++++
 5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/ISSUES.rst b/ISSUES.rst
index 639d021..1338c2e 100644
--- a/ISSUES.rst
+++ b/ISSUES.rst
@@ -17,7 +17,7 @@ Fix needed
 ==========
 
 test_image
-   test_figimage0[pdf], test_figimage1[pdf], test_interp_nearest_vs_none[pdf,svg], test_rasterize_dpi[pdf,svg]
+   test_figimage[pdf], test_figimage0[pdf], test_figimage1[pdf], test_interp_nearest_vs_none[pdf,svg], test_rasterize_dpi[pdf,svg]
       Invalid dpi manipulations in vector output.
 
    test_jpeg_alpha
@@ -122,9 +122,18 @@ We do not support writing PS to text-mode streams. ::
 
    test_backend_ps::test_savefig_to_stringio
 
+We support mixed usetex/non-usetex PS. ::
+
+   test_backend_ps::test_partial_usetex
+
 Tight bboxes are different. ::
 
    test_bbox_tight::test_bbox_inches_tight_suptile_legend
+   test_polar::test_get_tightbbox_polar
+
+We already raise on invalid savefig kwargs. ::
+
+   test_figure::test_savefig_warns
 
 ``--tolerance`` subverts Matplotlib's test interface. ::
 
diff --git a/README.rst b/README.rst
index 42d8de6..12d3797 100644
--- a/README.rst
+++ b/README.rst
@@ -530,8 +530,8 @@ Known issues
 Missing support from cairo
 --------------------------
 
-- SVG output does not set URLs or ids on any element, as cairo provides no
-  support to do so.
+- SVG output does not support global metadata or set URLs or ids on any
+  element, as cairo provides no support to do so.
 - PS output does not respect SOURCE_DATE_EPOCH.
 - PS output does not support the ``Creator`` metadata key; however it supports
   the ``Title`` key.
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 1690d05..2a8d71e 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -83,7 +83,7 @@ steps:
 - bash: |
     export PYTHONFAULTHANDLER=1 &&
     ./run-mpl-test-suite.py --tolerance=50 \
-      --instafail --timeout=300 --junitxml=junit/test-results.xml &&
+      --instafail --timeout=300 --verbose --junitxml=junit/test-results.xml &&
     PYTHONIOENCODING=utf-8 ./run-examples.py
   displayName: 'Test'
 
diff --git a/lib/mplcairo/base.py b/lib/mplcairo/base.py
index 69c661c..3cfac34 100644
--- a/lib/mplcairo/base.py
+++ b/lib/mplcairo/base.py
@@ -93,7 +93,7 @@ def _for_fmt_output(cls, fmt, stream, width, height, dpi):
 
     @classmethod
     def _for_svgz_output(cls, stream, width, height, dpi):
-        gzip_file = GzipFile(fileobj=stream)
+        gzip_file = GzipFile(fileobj=stream, mode="w")
         obj = cls._for_svg_output(gzip_file, width, height, dpi)
         try:
             name = os.fsdecode(stream.name)
@@ -227,6 +227,9 @@ def draw(self):
         self.get_renderer(_ensure_cleared=True, _ensure_drawn=True)
         super().draw()
 
+    def buffer_rgba(self):  # NOTE: Needed for tests.
+        return self.get_renderer(_ensure_drawn=True).buffer_rgba()
+
     def copy_from_bbox(self, bbox):
         return self.get_renderer(_ensure_drawn=True).copy_from_bbox(bbox)
 
diff --git a/run-mpl-test-suite.py b/run-mpl-test-suite.py
index e78fc61..fc20ef8 100755
--- a/run-mpl-test-suite.py
+++ b/run-mpl-test-suite.py
@@ -107,6 +107,8 @@ def pytest_collection_modifyitems(session, config, items):
         for message, nodeids in [
             (knownfail_message, [
                 "test_image.py::test_jpeg_alpha",
+                "test_image.py::test_figimage[pdf-False]",
+                "test_image.py::test_figimage[pdf-True]",
                 "test_image.py::test_figimage0[pdf]",
                 "test_image.py::test_figimage1[pdf]",
             ]),
@@ -121,13 +123,20 @@ def pytest_collection_modifyitems(session, config, items):
                 "test_backend_pdf.py::test_multipage_keep_empty",
                 "test_backend_pdf.py::test_multipage_pagecount",
                 "test_backend_pdf.py::test_multipage_properfinalize",
+                "test_backend_ps.py::test_partial_usetex",
                 "test_backend_ps.py::test_savefig_to_stringio[",
                 "test_backend_ps.py::test_source_date_epoch",
                 "test_backend_svg.py::test_gid",
+                "test_backend_svg.py::test_svg_default_metadata",
+                "test_backend_svg.py::test_svg_metadata",
                 "test_backend_svg.py::test_svgnone_with_data_coordinates",
                 "test_backend_svg.py::test_text_urls",
+                "test_backend_svg.py::test_url",
+                "test_backend_svg.py::test_url_tick",
                 "test_bbox_tight.py::test_bbox_inches_tight_suptile_legend[",
+                "test_figure.py::test_savefig_warns",
                 "test_image.py::test_composite[",
+                "test_polar.py::test_get_tightbbox_polar",
                 "test_scale.py::test_logscale_mask[png]",
                 "test_simplification.py::test_throw_rendering_complexity_exceeded",
             ]),