diff --git a/lib/matplotlib/testing/__init__.py b/lib/matplotlib/testing/__init__.py index 4cdfe4bd8b9e..6b67a4aef16c 100644 --- a/lib/matplotlib/testing/__init__.py +++ b/lib/matplotlib/testing/__init__.py @@ -1,6 +1,7 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) +import functools import inspect import warnings from contextlib import contextmanager @@ -20,34 +21,10 @@ def is_called_from_pytest(): return getattr(matplotlib, '_called_from_pytest', False) -# stolen from pytest -def _getrawcode(obj, trycall=True): - """Return code object for given function.""" - try: - return obj.__code__ - except AttributeError: - obj = getattr(obj, 'im_func', obj) - obj = getattr(obj, 'func_code', obj) - obj = getattr(obj, 'f_code', obj) - obj = getattr(obj, '__code__', obj) - if trycall and not hasattr(obj, 'co_firstlineno'): - if hasattr(obj, '__call__') and not inspect.isclass(obj): - x = getrawcode(obj.__call__, trycall=False) - if hasattr(x, 'co_firstlineno'): - return x - return obj - - def _copy_metadata(src_func, tgt_func): """Replicates metadata of the function. Returns target function.""" - tgt_func.__dict__.update(src_func.__dict__) - tgt_func.__doc__ = src_func.__doc__ - tgt_func.__module__ = src_func.__module__ - tgt_func.__name__ = src_func.__name__ - if hasattr(src_func, '__qualname__'): - tgt_func.__qualname__ = src_func.__qualname__ - if not hasattr(tgt_func, 'compat_co_firstlineno'): - tgt_func.compat_co_firstlineno = _getrawcode(src_func).co_firstlineno + functools.update_wrapper(tgt_func, src_func) + tgt_func.__wrapped__ = src_func # Python2 compatibility. return tgt_func diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index b6684aa139ce..beaee2fa729c 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -364,7 +364,7 @@ def runner_wrapper(): return _copy_metadata(func, runner_wrapper) -def image_comparison(baseline_images=None, extensions=None, tol=0, +def image_comparison(baseline_images, extensions=None, tol=0, freetype_version=None, remove_text=False, savefig_kwarg=None, style='classic'): """ @@ -405,8 +405,6 @@ def image_comparison(baseline_images=None, extensions=None, tol=0, if desired. Defaults to the 'classic' style. """ - if baseline_images is None: - raise ValueError('baseline_images must be specified') if extensions is None: # default extensions to test