Skip to content
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

Switch to pytest in CI and add unstable dependency environment #1095

Merged
merged 21 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8f28373
Switch to pytest in CI and add unstable dependency environment
djhoese Feb 28, 2020
ce5f473
Update dev guide to mention change in running tests
djhoese Feb 28, 2020
ecfa384
Fix pytest link text to be less obnoxious
djhoese Feb 28, 2020
0e987e5
Add xarray dev version to unstable deps environment
djhoese Feb 28, 2020
7fd003f
Add pytest and pytest-cov dependency to appveyor
djhoese Feb 28, 2020
d8f6909
Fix satpy not being installed to the appveyor environment
djhoese Feb 28, 2020
33dec55
Remove test suites from compositor tests
djhoese Feb 28, 2020
ab2ec42
Remove test suites from enhancement tests
djhoese Feb 28, 2020
13d127b
Fix docstrings in viirs enhancement tests
djhoese Feb 28, 2020
ba7dce2
Remove test suites from tests in the root tests directory
djhoese Feb 28, 2020
bc11d33
Add geoviews to appveyor dependencies
djhoese Feb 28, 2020
7945a80
Remove test suites from reader tests
djhoese Feb 28, 2020
f45b7db
Remove test suites from writer tests
djhoese Feb 28, 2020
e0b9d85
Remove old python 2 cruft
djhoese Feb 28, 2020
c80b015
Remove unused mock import
djhoese Feb 28, 2020
0aea73d
Remove six dependency and other small fixes
djhoese Feb 28, 2020
806cdb0
Fix (hopefully) defining allow failure environments on travis
djhoese Feb 28, 2020
2f0bd5e
Move satpy/composites/__init__.py tests to tests/test_composites.py
djhoese Feb 29, 2020
cc05a80
Remove unused import in test_composites.py
djhoese Feb 29, 2020
7721c0c
Fix typo in satpy/tests/writer_tests/test_simple_image.py docstring
djhoese Mar 2, 2020
6ec63d5
Remove unused and deprecated get_area_slices (use pyresample now)
djhoese Mar 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- For works in progress choose "Create draft pull request" from the drop-down green button. -->

- [ ] Closes #xxxx <!-- remove if there is no corresponding issue, which should only be the case for minor changes -->
- [ ] Tests added and test suite added to parent suite <!-- for all bug fixes or enhancements -->
- [ ] Tests added <!-- for all bug fixes or enhancements -->
- [ ] Tests passed <!-- for all non-documentation changes -->
- [ ] Passes ``flake8 satpy`` <!-- remove if you did not edit any Python files -->
- [ ] Fully documented <!-- remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later -->
Expand Down
34 changes: 31 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ env:
global:
# Set defaults to avoid repeating in most cases
- PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
- NUMPY_VERSION=1.17
- NUMPY_VERSION=stable
- MAIN_CMD='python setup.py'
- CONDA_DEPENDENCIES='xarray dask distributed toolz Cython sphinx cartopy pillow matplotlib scipy pyyaml pyproj=2.4.1 pyresample coveralls coverage codecov behave netcdf4 h5py h5netcdf gdal rasterio imageio pyhdf mock libtiff geoviews zarr six python-eccodes'
- CONDA_DEPENDENCIES='xarray dask distributed toolz Cython sphinx cartopy pillow matplotlib scipy pyyaml
pyproj=2.4.1 pyresample coveralls coverage codecov behave netcdf4 h5py h5netcdf gdal rasterio imageio pyhdf
mock libtiff geoviews zarr six python-eccodes geoviews pytest pytest-cov'
- PIP_DEPENDENCIES='trollsift trollimage pyspectral pyorbital libtiff'
- SETUP_XVFB=False
- EVENT_TYPE='push pull_request'
- SETUP_CMD='test'
- CONDA_CHANNELS='conda-forge'
- CONDA_CHANNEL_PRIORITY='strict'
- UNSTABLE_DEPS=False
matrix:
include:
- env: PYTHON_VERSION=3.8
Expand All @@ -24,11 +27,36 @@ matrix:
- env: PYTHON_VERSION=3.7
os: osx
language: generic
- os: linux
env:
- PYTHON_VERSION=3.8
- UNSTABLE_DEPS=True
allow_failures:
- env: UNSTABLE_DEPS=True
install:
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- if [ "$UNSTABLE_DEPS" == "True" ]; then
python -m pip install
-f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com
--no-deps --pre --upgrade
matplotlib
numpy
pandas
scipy;
python -m pip install
--no-deps --upgrade
git+https://github.com/dask/dask
git+https://github.com/dask/distributed
git+https://github.com/zarr-developers/zarr
git+https://github.com/Unidata/cftime
git+https://github.com/mapbox/rasterio
git+https://github.com/pydata/bottleneck
git+https://github.com/pydata/xarray;
fi
- pip install --no-deps -e .
script:
- coverage run --source=satpy setup.py test
- pytest --cov=satpy satpy/tests
- coverage run -a --source=satpy -m behave satpy/tests/features --tags=-download
after_success:
- if [[ $PYTHON_VERSION == 3.8 ]]; then coveralls; codecov; fi
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ environment:
PYTHON: "C:\\conda"
MINICONDA_VERSION: "latest"
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
CONDA_DEPENDENCIES: "xarray dask distributed toolz Cython sphinx cartopy pillow matplotlib scipy pyyaml pyproj pyresample coverage netcdf4 h5py h5netcdf gdal rasterio imageio pyhdf mock libtiff zarr six"
CONDA_DEPENDENCIES: "xarray dask distributed toolz Cython sphinx cartopy pillow matplotlib scipy pyyaml pyproj pyresample coverage netcdf4 h5py h5netcdf gdal rasterio imageio pyhdf libtiff geoviews zarr six pytest pytest-cov"
PIP_DEPENDENCIES: "trollsift trollimage pyspectral pyorbital libtiff"
CONDA_CHANNELS: "conda-forge"

Expand All @@ -21,12 +21,13 @@ install:
- "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "conda activate test"
- "pip install --no-deps -e ."

build: false # Not a C# project, build stuff at the test step instead.

test_script:
# Build the compiled extension and run the project tests
- "%CMD_IN_ENV% python setup.py test"
- "%CMD_IN_ENV% pytest --cov=satpy satpy/tests"

after_test:
# If tests are successful, create a whl package for the project.
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def __getattr__(cls, name):
'pyorbital': ('https://pyorbital.readthedocs.io/en/stable', None),
'pyproj': ('https://pyproj4.github.io/pyproj/dev', None),
'pyresample': ('https://pyresample.readthedocs.io/en/stable', None),
'pytest': ('https://docs.pytest.org/en/stable/', None),
'python': ('https://docs.python.org/3', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
'trollimage': ('https://trollimage.readthedocs.io/en/stable', None),
Expand Down
7 changes: 4 additions & 3 deletions doc/source/dev_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ clone your fork. The package can then be installed in development by doing::
Running tests
=============

Satpy tests are written using the python :mod:`unittest` module and the tests
can be executed by running::
Satpy tests are written using the python :mod:`unittest` module and the
third-party :doc:`pytest <pytest:index>` package. Satpy tests can be executed by
running::

python setup.py test
pytest satpy/tests

Documentation
=============
Expand Down
51 changes: 2 additions & 49 deletions satpy/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014-2019 Satpy developers
# Copyright (c) 2014-2020 Satpy developers
#
# This file is part of satpy.
#
Expand All @@ -15,51 +15,4 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""The tests package.
"""

import logging
import sys

from satpy.tests import (reader_tests, test_dataset, test_file_handlers,
test_readers, test_resample, test_demo,
test_scene, test_utils, test_writers,
test_yaml_reader, writer_tests,
enhancement_tests, compositor_tests, test_multiscene,
test_crefl_utils, test_config)


if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest


def suite():
"""The global test suite.
"""
logging.basicConfig(level=logging.DEBUG)

mysuite = unittest.TestSuite()
mysuite.addTests(test_scene.suite())
mysuite.addTests(test_dataset.suite())
mysuite.addTests(test_writers.suite())
mysuite.addTests(test_readers.suite())
mysuite.addTests(test_resample.suite())
mysuite.addTests(test_demo.suite())
mysuite.addTests(test_yaml_reader.suite())
mysuite.addTests(reader_tests.suite())
mysuite.addTests(writer_tests.suite())
mysuite.addTests(test_file_handlers.suite())
mysuite.addTests(test_utils.suite())
mysuite.addTests(enhancement_tests.suite())
mysuite.addTests(compositor_tests.suite())
mysuite.addTests(test_multiscene.suite())
mysuite.addTests(test_crefl_utils.suite())
mysuite.addTests(test_config.suite())

return mysuite


def load_tests(loader, tests, pattern):
return suite()
"""The tests package."""
44 changes: 1 addition & 43 deletions satpy/tests/compositor_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
import numpy as np
from datetime import datetime
from satpy.tests.compositor_tests import test_abi, test_ahi, test_viirs

try:
from unittest import mock
except ImportError:
import mock

from unittest import mock
import unittest


Expand Down Expand Up @@ -1253,40 +1248,3 @@ def test_call(self):
np.testing.assert_allclose(res.sel(bands='B'), data.sel(bands='B'))
# The compositor should drop the original alpha band
np.testing.assert_allclose(res.sel(bands='A'), reference_alpha)


def suite():
"""Test suite for all reader tests."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTests(test_abi.suite())
mysuite.addTests(test_ahi.suite())
mysuite.addTests(test_viirs.suite())
mysuite.addTest(loader.loadTestsFromTestCase(TestMatchDataArrays))
mysuite.addTest(loader.loadTestsFromTestCase(TestRatioSharpenedCompositors))
mysuite.addTest(loader.loadTestsFromTestCase(TestSunZenithCorrector))
mysuite.addTest(loader.loadTestsFromTestCase(TestDifferenceCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestDayNightCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestFillingCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestSandwichCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestLuminanceSharpeningCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestInlineComposites))
mysuite.addTest(loader.loadTestsFromTestCase(TestColormapCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestPaletteCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestCloudTopHeightCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestSingleBandCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestGenericCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestNIRReflectance))
mysuite.addTest(loader.loadTestsFromTestCase(TestPrecipCloudsCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestAddBands))
mysuite.addTest(loader.loadTestsFromTestCase(TestBackgroundCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestStaticImageCompositor))
mysuite.addTest(loader.loadTestsFromTestCase(TestPSPAtmosphericalCorrection))
mysuite.addTest(loader.loadTestsFromTestCase(TestPSPRayleighReflectance))
mysuite.addTest(loader.loadTestsFromTestCase(TestMaskingCompositor))

return mysuite


if __name__ == '__main__':
unittest.main()
19 changes: 2 additions & 17 deletions satpy/tests/compositor_tests/test_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Tests for ABI compositors.
"""
"""Tests for ABI compositors."""

import sys

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
import unittest


class TestABIComposites(unittest.TestCase):
Expand Down Expand Up @@ -71,12 +65,3 @@ def test_simulated_green(self):
'toa_bidirectional_reflectance')
data = res.compute()
np.testing.assert_allclose(data, 0.28025)


def suite():
"""The test suite for test_abi.
"""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestABIComposites))
return mysuite
18 changes: 2 additions & 16 deletions satpy/tests/compositor_tests/test_ahi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Tests for AHI compositors.
"""
"""Tests for AHI compositors."""

import sys

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
import unittest


class TestAHIComposites(unittest.TestCase):
Expand Down Expand Up @@ -68,12 +63,3 @@ def test_corrected_green(self):
'toa_bidirectional_reflectance')
data = res.compute()
np.testing.assert_allclose(data, 0.2575)


def suite():
"""The test suite for test_ahi.
"""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestAHIComposites))
return mysuite
14 changes: 1 addition & 13 deletions satpy/tests/compositor_tests/test_viirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
"""Tests for VIIRS compositors."""

import unittest
try:
from unittest import mock
except ImportError:
import mock
import mock


class TestVIIRSComposites(unittest.TestCase):
Expand Down Expand Up @@ -526,12 +523,3 @@ def test_get_angles(self, get_satpos):
self.assertIsInstance(args[4], da.Array)
self.assertIsInstance(args[5], da.Array)
self.assertEqual(args[6], 0)


def suite():
"""Create test suite for test_ahi."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestVIIRSComposites))
mysuite.addTest(loader.loadTestsFromTestCase(ViirsReflectanceCorrectorTest))
return mysuite
20 changes: 0 additions & 20 deletions satpy/tests/enhancement_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,3 @@
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""The enhancements tests package."""

import sys

from satpy.tests.enhancement_tests import (test_enhancements, test_viirs,
test_abi)

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest


def suite():
"""Create test suite for all enhancement tests."""
mysuite = unittest.TestSuite()
mysuite.addTests(test_enhancements.suite())
mysuite.addTests(test_viirs.suite())
mysuite.addTests(test_abi.suite())

return mysuite
8 changes: 0 additions & 8 deletions satpy/tests/enhancement_tests/test_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,3 @@ def test_cimss_true_color_contrast(self):
img = XRImage(self.da)
cimss_true_color_contrast(img)
np.testing.assert_almost_equal(img.data.compute(), expected)


def suite():
"""Create the test suite for test_abi."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestABIEnhancement))
return mysuite
19 changes: 1 addition & 18 deletions satpy/tests/enhancement_tests/test_enhancements.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import numpy as np
import xarray as xr
import dask.array as da
try:
from unittest import mock
except ImportError:
import mock
from unittest import mock


class TestEnhancementStretch(unittest.TestCase):
Expand Down Expand Up @@ -394,17 +391,3 @@ def test_cmap_list(self):
self.assertEqual(cmap.values.shape[0], 4)
self.assertEqual(cmap.values[0], 2)
self.assertEqual(cmap.values[-1], 8)


def suite():
"""Create test suite for builtin enhancement functions."""
loader = unittest.TestLoader()
mysuite = unittest.TestSuite()
mysuite.addTest(loader.loadTestsFromTestCase(TestEnhancementStretch))
mysuite.addTest(loader.loadTestsFromTestCase(TestColormapLoading))

return mysuite


if __name__ == "__main__":
unittest.main()