Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca4d87a

Browse files
committed
Remove matplotlib.decorators.skipif.
It's a compatibility wrapper around nose/pytest, but has never been released.
1 parent d696029 commit ca4d87a

4 files changed

Lines changed: 5 additions & 98 deletions

File tree

lib/matplotlib/testing/_nose/decorators.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,6 @@
99
from .exceptions import KnownFailureDidNotFailTest
1010

1111

12-
def skipif(skip_condition, *args, **kwargs):
13-
if isinstance(skip_condition, bool) and 'reason' not in kwargs:
14-
raise ValueError("you need to specify reason=STRING "
15-
"when using booleans as conditions.")
16-
17-
def skip_decorator(func):
18-
import inspect
19-
20-
def skipper(*_args, **_kwargs):
21-
condition, msg = skip_condition, kwargs.get('reason') # local copy
22-
if isinstance(condition, six.string_types):
23-
globs = {'os': os, 'sys': sys}
24-
try:
25-
globs.update(func.__globals__)
26-
except AttributeError:
27-
globs.update(func.func_globals)
28-
if msg is None:
29-
msg = condition
30-
condition = eval(condition, globs)
31-
else:
32-
condition = bool(condition)
33-
34-
if condition:
35-
skip(msg)
36-
else:
37-
return func(*_args, **_kwargs)
38-
39-
if inspect.isclass(func):
40-
setup = getattr(func, 'setup_class', classmethod(lambda _: None))
41-
setup = skip_decorator(setup.__func__)
42-
setup = setup.__get__(func)
43-
setattr(func, 'setup_class', setup)
44-
return func
45-
46-
return copy_metadata(func, skipper)
47-
48-
return skip_decorator
49-
50-
5112
def knownfailureif(fail_condition, msg=None, known_exception_class=None):
5213
# based on numpy.testing.dec.knownfailureif
5314
if msg is None:

lib/matplotlib/testing/decorators.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@
3030
from .exceptions import ImageComparisonFailure
3131

3232

33-
def skipif(condition, *args, **kwargs):
34-
"""Skip the given test function if eval(condition) results in a True
35-
value.
36-
37-
Optionally specify a reason for better reporting.
38-
"""
39-
if is_called_from_pytest():
40-
import pytest
41-
return pytest.mark.skipif(condition, *args, **kwargs)
42-
else:
43-
from ._nose.decorators import skipif
44-
return skipif(condition, *args, **kwargs)
45-
46-
4733
def knownfailureif(fail_condition, msg=None, known_exception_class=None):
4834
"""
4935
@@ -516,6 +502,7 @@ def skip_if_command_unavailable(cmd):
516502
try:
517503
check_output(cmd)
518504
except:
519-
return skipif(True, reason='missing command: %s' % cmd[0])
505+
import pytest
506+
return pytest.mark.skip(reason='missing command: %s' % cmd[0])
520507

521508
return lambda f: f

lib/matplotlib/tests/test_basic.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,11 @@
44
import six
55
import sys
66

7-
from ..testing.decorators import skipif
8-
9-
10-
SKIPIF_CONDITION = []
11-
12-
13-
def setup_module():
14-
SKIPIF_CONDITION.append(None)
15-
167

178
def test_simple():
189
assert 1 + 1 == 2
1910

2011

21-
@skipif(True, reason="skipif decorator test with bool condition passed")
22-
def test_skipif_bool():
23-
assert False, "skipif decorator does not work with bool condition"
24-
25-
26-
@skipif('SKIPIF_CONDITION',
27-
reason="skipif decorator test with string condition passed")
28-
def test_skipif_string():
29-
assert False, "skipif decorator does not work with string condition"
30-
31-
32-
@skipif(True, reason="skipif decorator on class test passed")
33-
class Test_skipif_on_class(object):
34-
def test(self):
35-
assert False, "skipif decorator does not work on classes"
36-
37-
38-
class Test_skipif_on_method(object):
39-
@skipif(True, reason="skipif decorator on method test passed")
40-
def test(self):
41-
assert False, "skipif decorator does not work on methods"
42-
43-
44-
@skipif(True, reason="skipif decorator on classmethod test passed")
45-
class Test_skipif_on_classmethod(object):
46-
@classmethod
47-
def setup_class(cls):
48-
pass
49-
50-
def test(self):
51-
assert False, "skipif decorator does not work on classmethods"
52-
53-
5412
def test_override_builtins():
5513
import pylab
5614

lib/matplotlib/tests/test_font_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import tempfile
99
import warnings
1010

11+
import pytest
12+
1113
from matplotlib.font_manager import (
1214
findfont, FontProperties, fontManager, json_dump, json_load, get_font,
1315
get_fontconfig_fonts, is_opentype_cff_font, fontManager as fm)
1416
from matplotlib import rc_context
15-
from matplotlib.testing.decorators import skipif
1617

1718

1819
def test_font_priority():
@@ -64,6 +65,6 @@ def test_otf():
6465
assert res == is_opentype_cff_font(f)
6566

6667

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

0 commit comments

Comments
 (0)