-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix unintentional skipped tests #1557
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e98bf36
move requires_pynio to fix GH1531, refactor tests/__init__.py
36ad7c3
remove ModuleNotFoundError
8768d65
no pytest decorators on classes with multiple inheritance in test_bac…
18e01c9
wrap class decorators for tests
0220da5
Merge branch 'master' of github.com:pydata/xarray into fix/1531
27b635b
no more class decorators in test_backends
5b4c966
whats new and some more cleanup
5f73351
whatsnew update
6651516
use unittest skip decorators, way easier
993992d
update workaround comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from contextlib import contextmanager | ||
from distutils.version import LooseVersion | ||
import re | ||
import importlib | ||
|
||
import numpy as np | ||
from numpy.testing import assert_array_equal | ||
|
@@ -15,6 +16,20 @@ | |
from xarray.core.pycompat import PY3 | ||
from xarray.testing import assert_equal, assert_identical, assert_allclose | ||
|
||
|
||
def _importorskip(modname, minversion=None): | ||
try: | ||
mod = importlib.import_module(modname) | ||
has = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put everything from here on down an the |
||
if minversion is not None: | ||
if LooseVersion(mod.__version__) < LooseVersion(minversion): | ||
raise ImportError('Minimum version not satisfied') | ||
except ImportError: | ||
has = False | ||
func = pytest.mark.skipif((not has), reason='requires {}'.format(modname)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove redundant parentheses around |
||
return has, func | ||
|
||
|
||
try: | ||
import unittest2 as unittest | ||
except ImportError: | ||
|
@@ -25,111 +40,32 @@ | |
except ImportError: | ||
import mock | ||
|
||
try: | ||
import scipy | ||
has_scipy = True | ||
except ImportError: | ||
has_scipy = False | ||
|
||
try: | ||
import pydap.client | ||
has_pydap = True | ||
except ImportError: | ||
has_pydap = False | ||
|
||
try: | ||
import netCDF4 | ||
has_netCDF4 = True | ||
except ImportError: | ||
has_netCDF4 = False | ||
|
||
|
||
try: | ||
import h5netcdf | ||
has_h5netcdf = True | ||
except ImportError: | ||
has_h5netcdf = False | ||
|
||
|
||
try: | ||
import Nio | ||
has_pynio = True | ||
except ImportError: | ||
has_pynio = False | ||
|
||
has_matplotlib, requires_matplotlib = _importorskip('matplotlib') | ||
has_scipy, requires_scipy = _importorskip('scipy') | ||
has_pydap, requires_pydap = _importorskip('pydap.client') | ||
has_netCDF4, requires_netCDF4 = _importorskip('netCDF4') | ||
has_h5netcdf, requires_h5netcdf = _importorskip('h5netcdf') | ||
has_pynio, requires_pynio = _importorskip('pynio') | ||
has_dask, requires_dask = _importorskip('dask') | ||
has_bottleneck, requires_bottleneck = _importorskip('bottleneck') | ||
has_rasterio, requires_rasterio = _importorskip('rasterio') | ||
has_pathlib, requires_pathlib = _importorskip('pathlib') | ||
|
||
# some special cases | ||
has_scipy_or_netCDF4 = has_scipy or has_netCDF4 | ||
requires_scipy_or_netCDF4 = pytest.mark.skipif( | ||
not has_scipy_or_netCDF4, reason='requires scipy or netCDF4') | ||
if not has_pathlib: | ||
has_pathlib, requires_pathlib = _importorskip('pathlib2') | ||
|
||
try: | ||
import dask.array | ||
if has_dask: | ||
import dask | ||
dask.set_options(get=dask.get) | ||
has_dask = True | ||
except ImportError: | ||
has_dask = False | ||
|
||
|
||
try: | ||
import matplotlib | ||
has_matplotlib = True | ||
except ImportError: | ||
has_matplotlib = False | ||
|
||
|
||
try: | ||
import bottleneck | ||
if LooseVersion(bottleneck.__version__) < LooseVersion('1.1'): | ||
raise ImportError('Fall back to numpy') | ||
has_bottleneck = True | ||
except ImportError: | ||
has_bottleneck = False | ||
|
||
try: | ||
import rasterio | ||
has_rasterio = True | ||
except ImportError: | ||
has_rasterio = False | ||
|
||
try: | ||
import pathlib | ||
has_pathlib = True | ||
except ImportError: | ||
try: | ||
import pathlib2 | ||
has_pathlib = True | ||
except ImportError: | ||
has_pathlib = False | ||
|
||
|
||
# slighly simpler construction that the full functions. | ||
# Generally `pytest.importorskip('package')` inline is even easier | ||
requires_matplotlib = pytest.mark.skipif( | ||
not has_matplotlib, reason='requires matplotlib') | ||
requires_scipy = pytest.mark.skipif( | ||
not has_scipy, reason='requires scipy') | ||
requires_pydap = pytest.mark.skipif( | ||
not has_pydap, reason='requires pydap') | ||
requires_netCDF4 = pytest.mark.skipif( | ||
not has_netCDF4, reason='requires netCDF4') | ||
requires_h5netcdf = pytest.mark.skipif( | ||
not has_h5netcdf, reason='requires h5netcdf') | ||
requires_pynio = pytest.mark.skipif( | ||
not has_pynio, reason='requires pynio') | ||
requires_scipy_or_netCDF4 = pytest.mark.skipif( | ||
not has_scipy and not has_netCDF4, reason='requires scipy or netCDF4') | ||
requires_dask = pytest.mark.skipif( | ||
not has_dask, reason='requires dask') | ||
requires_bottleneck = pytest.mark.skipif( | ||
not has_bottleneck, reason='requires bottleneck') | ||
requires_rasterio = pytest.mark.skipif( | ||
not has_rasterio, reason='requires rasterio') | ||
requires_pathlib = pytest.mark.skipif( | ||
not has_pathlib, reason='requires pathlib / pathlib2' | ||
) | ||
|
||
|
||
try: | ||
_SKIP_FLAKY = not pytest.config.getoption("--run-flaky") | ||
_SKIP_NETWORK_TESTS = not pytest.config.getoption("--run-network-tests") | ||
except ValueError: | ||
except (ValueError, AttributeError): | ||
# Can't get config from pytest, e.g., because xarray is installed instead | ||
# of being run from a development version (and hence conftests.py is not | ||
# available). Don't run flaky tests. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary for xarray, but from a user (or distributor) perspective the bug is fixed. I would probably drop that part.