Closed
Description
Bug report
Bug summary
The test_backend_pgf.py::test_xelatex[pdf]
has started failing recently on Gentoo systems. It is most likely due to some package being updated but I haven't been able to figure out which one.
Code for reproduction
tox -e py39
or with existing tox venv:
. .tox/py39/bin/activate
pytest --pyargs matplotlib.tests.test_backend_pgf -l
Actual outcome
============================================================== test session starts ===============================================================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /tmp/matplotlib, configfile: pytest.ini
collected 24 items
lib/matplotlib/tests/test_backend_pgf.py ........F........sss.... [100%]
==================================================================== FAILURES ====================================================================
_______________________________________________________________ test_xelatex[pdf] ________________________________________________________________
expected = '/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex-expected.pdf'
actual = '/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf', tol = 0, in_decorator = True
def compare_images(expected, actual, tol, in_decorator=False):
"""
Compare two "image" files checking differences within a tolerance.
The two given filenames may point to files which are convertible to
PNG via the `.converter` dictionary. The underlying RMS is calculated
with the `.calculate_rms` function.
Parameters
----------
expected : str
The filename of the expected image.
actual : str
The filename of the actual image.
tol : float
The tolerance (a color value difference, where 255 is the
maximal difference). The test fails if the average pixel
difference is greater than this value.
in_decorator : bool
Determines the output format. If called from image_comparison
decorator, this should be True. (default=False)
Returns
-------
None or dict or str
Return *None* if the images are equal within the given tolerance.
If the images differ, the return value depends on *in_decorator*.
If *in_decorator* is true, a dict with the following entries is
returned:
- *rms*: The RMS of the image difference.
- *expected*: The filename of the expected image.
- *actual*: The filename of the actual image.
- *diff_image*: The filename of the difference image.
- *tol*: The comparison tolerance.
Otherwise, a human-readable multi-line string representation of this
information is returned.
Examples
--------
::
img1 = "./baseline/plot.png"
img2 = "./output/plot.png"
compare_images(img1, img2, 0.001)
"""
actual = os.fspath(actual)
if not os.path.exists(actual):
raise Exception("Output image %s does not exist." % actual)
if os.stat(actual).st_size == 0:
raise Exception("Output image file %s is empty." % actual)
# Convert the image to png
expected = os.fspath(expected)
if not os.path.exists(expected):
raise IOError('Baseline image %r does not exist.' % expected)
extension = expected.split('.')[-1]
if extension != 'png':
> actual = convert(actual, cache=True)
actual = '/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf'
expected = '/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex-expected.pdf'
extension = 'pdf'
in_decorator = True
tol = 0
lib/matplotlib/testing/compare.py:435:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lib/matplotlib/testing/compare.py:310: in convert
converter[path.suffix[1:]](path, newpath)
cache = True
cache_dir = PosixPath('/home/mgorny/.cache/matplotlib/test_cache')
cached_path = PosixPath('/home/mgorny/.cache/matplotlib/test_cache/5e7b55f5b7b4068856ffc1421de85fe0.png')
filename = '/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf'
hash_value = '5e7b55f5b7b4068856ffc1421de85fe0'
newpath = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex_pdf.png')
path = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <matplotlib.testing.compare._GSConverter object at 0x7ff5847b23a0>
orig = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf')
dest = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex_pdf.png')
def __call__(self, orig, dest):
if not self._proc:
self._proc = subprocess.Popen(
[mpl._get_executable_info("gs").executable,
"-dNOSAFER", "-dNOPAUSE", "-sDEVICE=png16m"],
# As far as I can see, ghostscript never outputs to stderr.
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
self._read_until(b"\nGS")
except _ConverterError as err:
raise OSError("Failed to start Ghostscript") from err
def encode_and_escape(name):
return (os.fsencode(name)
.replace(b"\\", b"\\\\")
.replace(b"(", br"\(")
.replace(b")", br"\)"))
self._proc.stdin.write(
b"<< /OutputFile ("
+ encode_and_escape(dest)
+ b") >> setpagedevice ("
+ encode_and_escape(orig)
+ b") run flush\n")
self._proc.stdin.flush()
# GS> if nothing left on the stack; GS<n> if n items left on the stack.
err = self._read_until(b"GS")
stack = self._read_until(b">")
if stack or not os.path.exists(dest):
> stack_size = int(stack[1:]) if stack else 0
E ValueError: invalid literal for int() with base 10: b'ate missing from Resources.\n Output may be incorrect.\nGS'
dest = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex_pdf.png')
encode_and_escape = <function _GSConverter.__call__.<locals>.encode_and_escape at 0x7ff5a467a5e0>
err = b"Processing pages 1 through 1.\nPage 1\n\n **** Error 'gs' ignored -- Ext"
orig = PosixPath('/tmp/matplotlib/result_images/test_backend_pgf/pgf_xelatex.pdf')
self = <matplotlib.testing.compare._GSConverter object at 0x7ff5847b23a0>
stack = b'tate missing from Resources.\n Output may be incorrect.\nGS'
lib/matplotlib/testing/compare.py:160: ValueError
============================================================ short test summary info =============================================================
FAILED lib/matplotlib/tests/test_backend_pgf.py::test_xelatex[pdf] - ValueError: invalid literal for int() with base 10: b'ate missing from Res...
==================================================== 1 failed, 20 passed, 3 skipped in 44.09s ====================================================
Expected outcome
Tests passing again ;-).
Matplotlib version
- Operating system: Gentoo Linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.4.2.post1110+g3a265b33f (git checkout) - Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: Python 3.9.5 (system)
- Jupyter version (if applicable): n/a
- Other libraries: ghostscript 9.54.0, texlive 2021
$ xelatex --version
XeTeX 3.141592653-2.6-0.999993 (TeX Live 2021 Gentoo Linux)
kpathsea version 6.3.3
Copyright 2021 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty. Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 69.1; using 69.1
Compiled with zlib version 1.2.11; using 1.2.11
Compiled with FreeType2 version 2.10.4; using 2.10.4
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 2.8.1; using 2.8.1
Compiled with libpng version 1.6.37+apng; using 1.6.37+apng
Compiled with pplib version v2.05 less toxic i hope
Compiled with fontconfig version 2.13.1; using 2.13.1
Metadata
Metadata
Assignees
Labels
No labels