Make more of testing/ pytest-independent. by anntzer · Pull Request #14562 · matplotlib/matplotlib · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/2019-05-19-AL.rst
8 changes: 8 additions & 0 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import subprocess
import sys
from tempfile import TemporaryFile
import unittest

import numpy as np
import PIL
Expand Down Expand Up @@ -252,6 +253,12 @@ def comparable_formats():
return ['png', *converter]


def _skip_if_uncomparable(ext):
"""Raise `unittest.SkipTest` if an *ext* files cannot be compared."""
if ext not in comparable_formats():
raise unittest.SkipTest(f"Lacking dependency to compare {ext} files")


def convert(filename, cache):
"""
Convert the named file to png; return the name of the created file.
Expand All @@ -264,6 +271,7 @@ def convert(filename, cache):
path = Path(filename)
if not path.exists():
raise IOError(f"{path} does not exist")
_skip_if_uncomparable(path.suffix[1:])
if path.suffix[1:] not in converter:
import pytest
pytest.skip(f"Don't know how to convert {path.suffix} files to png")
Expand Down
122 changes: 51 additions & 71 deletions lib/matplotlib/testing/decorators.py