Skip to content

Finish removing nose #7935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove matplotlib.decorators.skipif.
It's a compatibility wrapper around nose/pytest, but has never been
released.
  • Loading branch information
QuLogic committed Jan 27, 2017
commit ca4d87a61bc7e4b688766ba060a5c8842d20f9a6
39 changes: 0 additions & 39 deletions lib/matplotlib/testing/_nose/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,6 @@
from .exceptions import KnownFailureDidNotFailTest


def skipif(skip_condition, *args, **kwargs):
if isinstance(skip_condition, bool) and 'reason' not in kwargs:
raise ValueError("you need to specify reason=STRING "
"when using booleans as conditions.")

def skip_decorator(func):
import inspect

def skipper(*_args, **_kwargs):
condition, msg = skip_condition, kwargs.get('reason') # local copy
if isinstance(condition, six.string_types):
globs = {'os': os, 'sys': sys}
try:
globs.update(func.__globals__)
except AttributeError:
globs.update(func.func_globals)
if msg is None:
msg = condition
condition = eval(condition, globs)
else:
condition = bool(condition)

if condition:
skip(msg)
else:
return func(*_args, **_kwargs)

if inspect.isclass(func):
setup = getattr(func, 'setup_class', classmethod(lambda _: None))
setup = skip_decorator(setup.__func__)
setup = setup.__get__(func)
setattr(func, 'setup_class', setup)
return func

return copy_metadata(func, skipper)

return skip_decorator


def knownfailureif(fail_condition, msg=None, known_exception_class=None):
# based on numpy.testing.dec.knownfailureif
if msg is None:
Expand Down
17 changes: 2 additions & 15 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@
from .exceptions import ImageComparisonFailure


def skipif(condition, *args, **kwargs):
"""Skip the given test function if eval(condition) results in a True
value.

Optionally specify a reason for better reporting.
"""
if is_called_from_pytest():
import pytest
return pytest.mark.skipif(condition, *args, **kwargs)
else:
from ._nose.decorators import skipif
return skipif(condition, *args, **kwargs)


def knownfailureif(fail_condition, msg=None, known_exception_class=None):
"""

Expand Down Expand Up @@ -516,6 +502,7 @@ def skip_if_command_unavailable(cmd):
try:
check_output(cmd)
except:
return skipif(True, reason='missing command: %s' % cmd[0])
import pytest
return pytest.mark.skip(reason='missing command: %s' % cmd[0])

return lambda f: f
42 changes: 0 additions & 42 deletions lib/matplotlib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,11 @@
import six
import sys

from ..testing.decorators import skipif


SKIPIF_CONDITION = []


def setup_module():
SKIPIF_CONDITION.append(None)


def test_simple():
assert 1 + 1 == 2


@skipif(True, reason="skipif decorator test with bool condition passed")
def test_skipif_bool():
assert False, "skipif decorator does not work with bool condition"


@skipif('SKIPIF_CONDITION',
reason="skipif decorator test with string condition passed")
def test_skipif_string():
assert False, "skipif decorator does not work with string condition"


@skipif(True, reason="skipif decorator on class test passed")
class Test_skipif_on_class(object):
def test(self):
assert False, "skipif decorator does not work on classes"


class Test_skipif_on_method(object):
@skipif(True, reason="skipif decorator on method test passed")
def test(self):
assert False, "skipif decorator does not work on methods"


@skipif(True, reason="skipif decorator on classmethod test passed")
class Test_skipif_on_classmethod(object):
@classmethod
def setup_class(cls):
pass

def test(self):
assert False, "skipif decorator does not work on classmethods"


def test_override_builtins():
import pylab

Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import tempfile
import warnings

import pytest

from matplotlib.font_manager import (
findfont, FontProperties, fontManager, json_dump, json_load, get_font,
get_fontconfig_fonts, is_opentype_cff_font, fontManager as fm)
from matplotlib import rc_context
from matplotlib.testing.decorators import skipif


def test_font_priority():
Expand Down Expand Up @@ -64,6 +65,6 @@ def test_otf():
assert res == is_opentype_cff_font(f)


@skipif(sys.platform == 'win32', reason='no fontconfig on Windows')
@pytest.mark.skipif(sys.platform == 'win32', reason='no fontconfig on Windows')
def test_get_fontconfig_fonts():
assert len(get_fontconfig_fonts()) > 1