Skip to content

Commit 58878db

Browse files
committed
Adds marked tests as slow, flakey, and optionalci
Tests are marked using the following py.test options: * @slow which is run on default, not run if `--skip-slow` * @optionalci is run on default, not run if `--skip-optional-ci` * @flakey which is not run on default, run if `--run-flakey` Note, the `optionalci` category is needed in order to mark tests that are environment dependent when run on continuous integration (CI) hardware.
1 parent 371d034 commit 58878db

File tree

6 files changed

+131
-15
lines changed

6 files changed

+131
-15
lines changed

.travis.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@ matrix:
1212
include:
1313
- python: 2.7
1414
env: CONDA_ENV=py27-min
15+
- python: 2.7
16+
env: CONDA_ENV=py27-min SKIP_CI=--skip-optional-ci
1517
- python: 2.7
1618
env: CONDA_ENV=py27-cdat+pynio
19+
- python: 2.7
20+
env: CONDA_ENV=py27-cdat+pynio SKIP_CI=--skip-optional-ci
1721
- python: 3.4
1822
env: CONDA_ENV=py34
23+
- python: 3.4
24+
env: CONDA_ENV=py34 SKIP_CI=--skip-optional-ci
1925
- python: 3.5
2026
env: CONDA_ENV=py35
27+
- python: 3.5
28+
env: CONDA_ENV=py35 SKIP_CI=--skip-optional-ci
2129
- python: 3.6
2230
env: CONDA_ENV=py36
31+
- python: 3.6
32+
env: CONDA_ENV=py36 SKIP_CI=--skip-optional-ci
2333
- python: 3.6
2434
env: CONDA_ENV=py36-pydap
2535
- python: 3.6
@@ -51,6 +61,28 @@ matrix:
5161
env: CONDA_ENV=py36-pandas-dev
5262
- python: 3.6
5363
env: CONDA_ENV=py36-condaforge-rc
64+
- python: 2.7
65+
env: CONDA_ENV=py27-min
66+
- python: 2.7
67+
env: CONDA_ENV=py27-cdat+pynio
68+
- python: 3.4
69+
env: CONDA_ENV=py34
70+
- python: 3.5
71+
env: CONDA_ENV=py35
72+
- python: 3.6
73+
env: CONDA_ENV=py36
74+
- python: 3.6
75+
env: CONDA_ENV=py36-pydap
76+
- python: 2.7
77+
env: CONDA_ENV=py27-min
78+
- python: 2.7
79+
env: CONDA_ENV=py27-cdat+pynio
80+
- python: 3.4
81+
env: CONDA_ENV=py34
82+
- python: 3.5
83+
env: CONDA_ENV=py35
84+
- python: 3.6
85+
env: CONDA_ENV=py36
5486

5587
before_install:
5688
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
@@ -76,7 +108,7 @@ install:
76108
- python setup.py install
77109

78110
script:
79-
- py.test xarray --cov=xarray --cov-report term-missing --verbose
111+
- py.test xarray --cov=xarray --cov-report term-missing --verbose $SKIP_CI
80112

81113
after_success:
82114
- coveralls

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ install:
3838
build: false
3939

4040
test_script:
41-
- "py.test xarray --verbose"
41+
- "py.test xarray --verbose --skip-optional-ci"

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
def pytest_addoption(parser):
4+
parser.addoption("--run-flakey", action="store_true",
5+
help="runs flakey tests")
6+
parser.addoption("--skip-optional-ci", action="store_true",
7+
help="skips optional tests continuous integration (CI)")
8+
parser.addoption("--skip-slow", action="store_true",
9+
help="skips slow tests")

xarray/tests/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ def requires_bottleneck(test):
114114
return test if has_bottleneck else pytest.mark.skip('requires bottleneck')(test)
115115

116116

117+
flakey = pytest.mark.skipif(
118+
not pytest.config.getoption("--run-flakey"),
119+
reason="set --run-flakey option to run flakey tests"
120+
)
121+
122+
optionalci = pytest.mark.skipif(
123+
pytest.config.getoption("--skip-optional-ci"),
124+
reason=("set --skip-optional-ci option to skip tests in CI, "
125+
"e.g., due to travis CI resource issues")
126+
)
127+
128+
129+
slow = pytest.mark.skipif(
130+
pytest.config.getoption("--skip-slow"),
131+
reason="set --skip-slow option to run slow tests"
132+
)
133+
134+
117135
class TestCase(unittest.TestCase):
118136
if PY3:
119137
# Python 3 assertCountEqual is roughly equivalent to Python 2

xarray/tests/test_backends.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
from . import (TestCase, requires_scipy, requires_netCDF4, requires_pydap,
2828
requires_scipy_or_netCDF4, requires_dask, requires_h5netcdf,
29-
requires_pynio, has_netCDF4, has_scipy, assert_allclose)
29+
requires_pynio, has_netCDF4, has_scipy, assert_allclose,
30+
flakey, optionalci, slow)
3031
from .test_dataset import create_test_data
3132

3233
try:
@@ -1059,8 +1060,9 @@ def test_encoding_unlimited_dims(self):
10591060
ds.to_netcdf(tmp_file, engine='h5netcdf', unlimited_dims=['y'])
10601061

10611062
# tests pending h5netcdf fix
1062-
# class H5NetCDFDataTestAutocloseTrue(H5NetCDFDataTest):
1063-
# autoclose = True
1063+
@flakey
1064+
class H5NetCDFDataTestAutocloseTrue(H5NetCDFDataTest):
1065+
autoclose = True
10641066

10651067

10661068
class OpenMFDatasetManyFilesTest(TestCase):
@@ -1105,32 +1107,42 @@ def test_3_autoclose_pynio(self):
11051107

11061108
# use of autoclose=True with h5netcdf broken because of
11071109
# probable h5netcdf error, uncomment when fixed to test
1108-
# @requires_dask
1109-
# @requires_h5netcdf
1110-
# def test_4_autoclose_h5netcdf(self):
1111-
# self.validate_open_mfdataset_autoclose(engine=['h5netcdf'])
1110+
@requires_dask
1111+
@requires_h5netcdf
1112+
@flakey
1113+
def test_4_autoclose_h5netcdf(self):
1114+
self.validate_open_mfdataset_autoclose(engine=['h5netcdf'])
11121115

11131116
@requires_dask
11141117
@requires_netCDF4
1118+
@optionalci
1119+
@slow
11151120
def test_1_open_large_num_files_netcdf4(self):
11161121
self.validate_open_mfdataset_large_num_files(engine=['netcdf4'])
11171122

11181123
@requires_dask
11191124
@requires_scipy
1125+
@optionalci
1126+
@slow
11201127
def test_2_open_large_num_files_scipy(self):
11211128
self.validate_open_mfdataset_large_num_files(engine=['scipy'])
11221129

11231130
@requires_dask
11241131
@requires_pynio
1132+
@optionalci
1133+
@slow
11251134
def test_3_open_large_num_files_pynio(self):
11261135
self.validate_open_mfdataset_large_num_files(engine=['pynio'])
11271136

11281137
# use of autoclose=True with h5netcdf broken because of
11291138
# probable h5netcdf error, uncomment when fixed to test
1130-
# @requires_dask
1131-
# @requires_h5netcdf
1132-
# def test_4_open_large_num_files_h5netcdf(self):
1133-
# self.validate_open_mfdataset_large_num_files(engine=['h5netcdf'])
1139+
@requires_dask
1140+
@requires_h5netcdf
1141+
@flakey
1142+
@optionalci
1143+
@slow
1144+
def test_4_open_large_num_files_h5netcdf(self):
1145+
self.validate_open_mfdataset_large_num_files(engine=['h5netcdf'])
11341146

11351147

11361148
@requires_dask

0 commit comments

Comments
 (0)