8000 Remove old nose testing code · matplotlib/matplotlib@d879ee8 · GitHub
[go: up one dir, main page]

Skip to content

Commit d879ee8

Browse files
committed
Remove old nose testing code
1 parent a94f839 commit d879ee8

File tree

10 files changed

+6
-361
lines changed

10 files changed

+6
-361
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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +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)
56-
57-
58-
@cbook.deprecated('2.1',
59-
alternative='pytest.xfail or import the plugin')
60-
def knownfailureif(fail_condition, msg=None, known_exception_class=None):
61-
_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)
6252

6353

6454
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 & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -78,124 +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-
def nosetest_manual_text_removal():
100-
from matplotlib.testing.decorators import ImageComparisonTest
101-
102-
fig = nosetest_simple_figure()
103-
with warnings.catch_warnings(record=True) as w:
104-
warnings.simplefilter('always')
105-
# Make sure this removes text like it should.
106-
ImageComparisonTest.remove_text(fig)
107-
108-
assert len(w) == 1
109-
assert 'remove_text function was deprecated in version 2.1.' in str(w[0])
110-
111-
112-
@pytest.mark.parametrize(
113-
'func, kwargs, errors, failures, dots',
114-
[
115-
(nosetest_empty, {'baseline_images': []}, [], [], ''),
116-
(nosetest_empty, {'baseline_images': ['foo']},
117-
[(AssertionError,
118-
'Test generated 0 images but there are 1 baseline images')],
119-
[],
120-
'E'),
121-
(nosetest_simple_figure,
122-
{'baseline_images': ['basn3p02'], 'extensions': ['png'],
123-
'remove_text': True},
124-
[],
125-
[(ImageComparisonFailure, 'Image sizes do not match expected size:')],
126-
'F'),
127-
(nosetest_simple_figure,
128-
{'baseline_images': ['simple']},
129-
[],
130-
[(ImageComparisonFailure, 'images not close')] * 3,
131-
'FFF'),
132-
(nosetest_simple_figure,
133-
{'baseline_images': ['simple'], 'remove_text': True},
134-
[],
135-
[],
136-
'...'),
137-
(nosetest_manual_text_removal,
138-
{'baseline_images': ['simple']},
139-
[],
140-
[],
141-
'...'),
142-
],
143-
ids=[
144-
'empty',
145-
'extra baselines',
146-
'incorrect shape',
147-
'failing figure',
148-
'passing figure',
149-
'manual text removal',
150-
])
151-
def test_nose_image_comparison(func, kwargs, errors, failures, dots,
152-
monkeypatch):
153-
nose = pytest.importorskip('nose')
154-
monkeypatch.setattr('matplotlib._called_from_pytest', False)
155-
156-
class TestResultVerifier(nose.result.TextTestResult):
157-
def __init__(self, *args, **kwargs):
158-
super().__init__(*args, **kwargs)
159-
self.error_count = 0
160-
self.failure_count = 0
161-
162-
def addError(self, test, err):
163-
super().addError(test, err)
164-
165-
if self.error_count < len(errors):
166-
assert err[0] is errors[self.error_count][0]
167-
assert errors[self.error_count][1] in str(err[1])
168-
else:
169-
raise err[1]
170-
self.error_count += 1
171-
172-
def addFailure(self, test, err):
173-
super().addFailure(test, err)
174-
175-
assert self.failure_count < len(failures), err[1]
176-
assert err[0] is failures[self.failure_count][0]
177-
assert failures[self.failure_count][1] in str(err[1])
178-
self.failure_count += 1
179-
180-
# Make sure that multiple extensions work, but don't require LaTeX or
181-
# Inkscape to do so.
182-
kwargs.setdefault('extensions', ['png', 'png', 'png'])
183-
184-
func = image_comparison(**kwargs)(func)
185-
loader = nose.loader.TestLoader()
186-
suite = loader.loadTestsFromGenerator(
187-
func,
188-
'matplotlib.tests.test_compare_images')
189-
if six.PY2:
190-
output = io.BytesIO()
191-
else:
192-
output = io.StringIO()
193-
result = TestResultVerifier(stream=output, descriptions=True, verbosity=1)
194-
with warnings.catch_warnings():
195-
# Nose uses deprecated stuff; we don't care about it.
196-
warnings.simplefilter('ignore', DeprecationWarning)
197-
suite.run(result=result)
198-
199-
assert output.getvalue() == dots
200-
assert result.error_count == len(errors)
201-
assert result.failure_count == len(failures)

setupext.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,6 @@ def get_packages(self):
714714
'matplotlib.sphinxext',
715715
'matplotlib.style',
716716
'matplotlib.testing',
717-
'matplotlib.testing._nose',
718-
'matplotlib.testing._nose.plugins',
719717
'matplotlib.testing.jpl_units',
720718
'matplotlib.tri',
721719
'matplotlib.cbook'

0 commit comments

Comments
 (0)
0