8000 Remove old nose testing code by dstansby · Pull Request #9918 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove old nose testing code #9918

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 3 commits into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/2018-02-15-DS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deprecated methods removed from `matplotlib.testing`
----------------------------------------------------

The deprecated methods `knownfailureif` and `remove_text` have been removed
from :mod:`matplotlib.testing.decorators`.

The entire contents of `testing.noseclasses` have also been removed.
78 changes: 0 additions & 78 deletions lib/matplotlib/testing/_nose/__init__.py

This file was deleted.

33 changes: 0 additions & 33 deletions lib/matplotlib/testing/_nose/decorators.py

This file was deleted.

10 changes: 0 additions & 10 deletions lib/matplotlib/testing/_nose/exceptions.py

This file was deleted.

Empty file.
49 changes: 0 additions & 49 deletions lib/matplotlib/testing/_nose/plugins/knownfailure.py

This file was deleted.

26 changes: 0 additions & 26 deletions lib/matplotlib/testing/_nose/plugins/performgc.py

This file was deleted.

16 changes: 6 additions & 10 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ def _knownfailureif(fail_condition, msg=None, known_exception_class=None):
if the exception is an instance of this class. (Default = None)

"""
if is_called_from_pytest():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is private, so we should probably just replace its callers with the direct pytest marker call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically it is public but we should still do the switch and deprecate it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it isn't. The one being removed below is public, but it's already deprecated. This one is private.

Copy link
Member
@QuLogic QuLogic Feb 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you meant is_called_from_pytest; I meant the function in which this code exists: _knownfailureif.

import pytest
if fail_condition == 'indeterminate':
fail_condition, strict = True, False
else:
fail_condition, strict = bool(fail_condition), True
return pytest.mark.xfail(condition=fail_condition, reason=msg,
raises=known_exception_class, strict=strict)
import pytest
if fail_condition == 'indeterminate':
fail_condition, strict = True, False
else:
from ._nose.decorators import knownfailureif
return knownfailureif(fail_condition, msg, known_exception_class)
fail_condition, strict = bool(fail_condition), True
return pytest.mark.xfail(condition=fail_condition, reason=msg,
raises=known_exception_class, strict=strict)


def _do_cleanup(original_units_registry, original_settings):
Expand Down
26 changes: 0 additions & 26 deletions lib/matplotlib/testing/noseclasses.py

This file was deleted.

102 changes: 0 additions & 102 deletions lib/matplotlib/tests/test_compare_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,105 +78,3 @@ def test_image_comparison_expect_rms(im1, im2, tol, expect_rms):
else:
assert results is not None
assert results['rms'] == approx(expect_rms, abs=1e-4)


# The following tests are used by test_nose_image_comparison to ensure that the
# image_comparison decorator continues to work with nose. They should not be
# prefixed by test_ so they don't run with pytest.


def nosetest_empty():
pass


def nosetest_simple_figure():
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(6.4, 4), dpi=100)
ax.plot([1, 2, 3], [3, 4, 5])
return fig


@pytest.mark.parametrize(
'func, kwargs, errors, failures, dots' A3E2 ,
[
(nosetest_empty, {'baseline_images': []}, [], [], ''),
(nosetest_empty, {'baseline_images': ['foo']},
[(AssertionError,
'Test generated 0 images but there are 1 baseline images')],
[],
'E'),
(nosetest_simple_figure,
{'baseline_images': ['basn3p02'], 'extensions': ['png'],
'remove_text': True},
[],
[(ImageComparisonFailure, 'Image sizes do not match expected size:')],
'F'),
(nosetest_simple_figure,
{'baseline_images': ['simple']},
[],
[(ImageComparisonFailure, 'images not close')] * 3,
'FFF'),
(nosetest_simple_figure,
{'baseline_images': ['simple'], 'remove_text': True},
[],
[],
'...'),
],
ids=[
'empty',
'extra baselines',
'incorrect shape',
'failing figure',
'passing figure',
])
def test_nose_image_comparison(func, kwargs, errors, failures, dots,
monkeypatch):
nose = pytest.importorskip('nose')
monkeypatch.setattr('matplotlib._called_from_pytest', False)

class TestResultVerifier(nose.result.TextTestResult):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.error_count = 0
self.failure_count = 0

def addError(self, test, err):
super().addError(test, err)

if self.error_count < len(errors):
assert err[0] is errors[self.error_count][0]
assert errors[self.error_count][1] in str(err[1])
else:
raise err[1]
self.error_count += 1

def addFailure(self, test, err):
super().addFailure(test, err)

assert self.failure_count < len(failures), err[1]
assert err[0] is failures[self.failure_count][0]
assert failures[self.failure_count][1] in str(err[1])
self.failure_count += 1

# Make sure that multiple extensions work, but don't require LaTeX or
# Inkscape to do so.
kwargs.setdefault('extensions', ['png', 'png', 'png'])

func = image_comparison(**kwargs)(func)
loader = nose.loader.TestLoader()
suite = loader.loadTestsFromGenerator(
func,
'matplotlib.tests.test_compare_images')
if six.PY2:
output = io.BytesIO()
else:
output = io.StringIO()
result = TestResultVerifier(stream=output, descriptions=True, verbosity=1)
with warnings.catch_warnings():
# Nose uses deprecated stuff; we don't care about it.
warnings.simplefilter('ignore', DeprecationWarning)
suite.run(result=result)

assert output.getvalue() == dots
assert result.error_count == len(errors)
assert result.failure_count == len(failures)
0