-
Notifications
You must be signed in to change notification settings - Fork 48
pytest.skip not respected after initial figure created in a test #172
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
Comments
We're also seeing this over in MetPy where we have a decorator that uses def needs_cartopy(test_func):
"""Decorate a test function or fixture as requiring CartoPy.
Will skip the decorated test, or any test using the decorated fixture, if ``cartopy`` is
unable to be imported.
"""
@functools.wraps(test_func)
def wrapped(*args, **kwargs):
pytest.importorskip('cartopy')
return test_func(*args, **kwargs)
return wrapped |
Prior to The issue is that in the There is a very simple fix for this which will work for #171, so I'll push an update to that PR tomorrow which will solve this issue. (And I'll add some tests for this issue.) This PR introduces yet another change to the pytest hooks. Maybe the best option would be to revert to the pre pytest-mpl/pytest_mpl/plugin.py Lines 736 to 740 in 48e652f
|
If the return value hasn't been added to the dictionary, it means that the user's test didn't reach the end. This means that it raised an exception or was otherwise stopped early by pytest (skipped, failed, etc). In any case, we should not proceed with figure testing and use the result that pytest has already determined. Fixes matplotlib#172
In Cartopy, we have some parameterized tests that create a figure, try to do some things on that figure in a try/except clause, and if it hits the exception throw a
pytest.skip()
to indicate we want to skip that test. In the recent 0.16 release, this no longer works and the images are compared and produce a failure due to their being no image to compare against (since we want it skipped). See comment here: SciTools/cartopy#2058 (review)The text was updated successfully, but these errors were encountered: