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

Skip to content

Commit 6a58143

Browse files
committed
Remove old nose testing code
1 parent 3208322 commit 6a58143

File tree

9 files changed

+6
-334
lines changed

9 files changed

+6
-334
lines changed

lib/matplotlib/testing/_nose/__init__.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

lib/matplotlib/testing/_nose/decorators.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

lib/matplotlib/testing/_nose/exceptions.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/matplotlib/testing/_nose/plugins/__init__.py

Whitespace-only changes.

lib/matplotlib/testing/_nose/plugins/knownfailure.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

lib/matplotlib/testing/_nose/plugins/performgc.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/matplotlib/testing/decorators.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ def _knownfailureif(fail_condition, msg=None, known_exception_class=None):
4242
if the exception is an instance of this class. (Default = None)
4343
4444
"""
45-
if is_called_from_pytest():
46-
import pytest
47-
if fail_condition == 'indeterminate':
48-
fail_condition, strict = True, False
49-
else:
50-
fail_condition, strict = bool(fail_condition), True
51-
return pytest.mark.xfail(condition=fail_condition, reason=msg,
52-
raises=known_exception_class, strict=strict)
45+
import pytest
46+
if fail_condition == 'indeterminate':
47+
fail_condition, strict = True, False
5348
else:
54-
from ._nose.decorators import knownfailureif
55-
return knownfailureif(fail_condition, msg, known_exception_class)
49+
fail_condition, strict = bool(fail_condition), True
50+
return pytest.mark.xfail(condition=fail_condition, reason=msg,
51+
raises=known_exception_class, strict=strict)
5652

5753

5854
def _do_cleanup(original_units_registry, original_settings):

lib/matplotlib/testing/noseclasses.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/matplotlib/tests/test_compare_images.py

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -78,105 +78,3 @@ def test_image_comparison_expect_rms(im1, im2, tol, expect_rms):
7878
else:
7979
assert results is not None
8080
assert results['rms'] == approx(expect_rms, abs=1e-4)
81-
82-
83-
# The following tests are used by test_nose_image_comparison to ensure that the
84-
# image_comparison decorator continues to work with nose. They should not be
85-
# prefixed by test_ so they don't run with pytest.
86-
87-
88-
def nosetest_empty():
89-
pass
90-
91-
92-
def nosetest_simple_figure():
93-
import matplotlib.pyplot as plt
94-
fig, ax = plt.subplots(figsize=(6.4, 4), dpi=100)
95-
ax.plot([1, 2, 3], [3, 4, 5])
96-
return fig
97-
98-
99-
@pytest.mark.parametrize(
100-
'func, kwargs, errors, failures, dots',
101-
[
102-
(nosetest_empty, {'baseline_images': []}, [], [], ''),
103-
(nosetest_empty, {'baseline_images': ['foo']},
104-
[(AssertionError,
105-
'Test generated 0 images but there are 1 baseline images')],
106-
[],
107-
'E'),
108-
(nosetest_simple_figure,
109-
{'baseline_images': ['basn3p02'], 'extensions': ['png'],
110-
'remove_text': True},
111-
[],
112-
[(ImageComparisonFailure, 'Image sizes do not match expected size:')],
113-
'F'),
114-
(nosetest_simple_figure,
115-
{'baseline_images': ['simple']},
116-
[],
117-
[(ImageComparisonFailure, 'images not close')] * 3,
118-
'FFF'),
119-
(nosetest_simple_figure,
120-
{'baseline_images': ['simple'], 'remove_text': True},
121-
[],
122-
[],
123-
'...'),
124-
],
125-
ids=[
126-
'empty',
127-
'extra baselines',
128-
'incorrect shape',
129-
'failing figure',
130-
'passing figure',
131-
])
132-
def test_nose_image_comparison(func, kwargs, errors, failures, dots,
133-
monkeypatch):
134-
nose = pytest.importorskip('nose')
135-
monkeypatch.setattr('matplotlib._called_from_pytest', False)
136-
137-
class TestResultVerifier(nose.result.TextTestResult):
138-
def __init__(self, *args, **kwargs):
139-
super().__init__(*args, **kwargs)
140-
self.error_count = 0
141-
self.failure_count = 0
142-
143-
def addError(self, test, err):
144-
super().addError(test, err)
145-
146-
if self.error_count < len(errors):
147-
assert err[0] is errors[self.error_count][0]
148-
assert errors[self.error_count][1] in str(err[1])
149-
else:
150-
raise err[1]
151-
self.error_count += 1
152-
153-
def addFailure(self, test, err):
154-
super().addFailure(test, err)
155-
156-
assert self.failure_count < len(failures), err[1]
157-
assert err[0] is failures[self.failure_count][0]
158-
assert failures[self.failure_count][1] in str(err[1])
159-
self.failure_count += 1
160-
161-
# Make sure that multiple extensions work, but don't require LaTeX or
162-
# Inkscape to do so.
163-
kwargs.setdefault('extensions', ['png', 'png', 'png'])
164-
165-
func = image_comparison(**kwargs)(func)
166-
loader = nose.loader.TestLoader()
167-
suite = loader.loadTestsFromGenerator(
168-
func,
169-
'matplotlib.tests.test_compare_images')
170-
if six.PY2:
171-
output = io.BytesIO()
172-
else:
173-
output = io.StringIO()
174-
result = TestResultVerifier(stream=output, descriptions=True, verbosity=1)
175-
with warnings.catch_warnings():
176-
# Nose uses deprecated stuff; we don't care about it.
177-
warnings.simplefilter('ignore', DeprecationWarning)
178-
suite.run(result=result)
179-
180-
assert output.getvalue() == dots
181-
assert result.error_count == len(errors)
182-
assert result.failure_count == len(failures)

0 commit comments

Comments
 (0)