Skip to content

Commit

Permalink
Merge pull request SciTools#1032 from QuLogic/test-updates
Browse files Browse the repository at this point in the history
Improvements to test metadata
  • Loading branch information
pelson authored Feb 23, 2018
2 parents ac936e5 + 062485e commit 67e0113
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 44 deletions.
5 changes: 3 additions & 2 deletions lib/cartopy/_epsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

from __future__ import (absolute_import, division, print_function)

import cartopy.crs as ccrs
import numpy as np
import pyepsg
import shapely.geometry as sgeom

import cartopy.crs as ccrs


_GLOBE_PARAMS = {'datum': 'datum',
'ellps': 'ellipse',
Expand All @@ -39,6 +39,7 @@

class _EPSGProjection(ccrs.Projection):
def __init__(self, code):
import pyepsg
projection = pyepsg.get(code)
if not isinstance(projection, pyepsg.ProjectedCRS):
raise ValueError('EPSG code does not define a projection')
Expand Down
4 changes: 3 additions & 1 deletion lib/cartopy/tests/io/test_downloaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -107,6 +107,7 @@ def test_from_config():
assert r is land_downloader


@pytest.mark.network
def test_downloading_simple_ascii(download_to_temp):
# downloads a file from the Google APIs. (very high uptime and file will
# always be there - if this goes down, most of the internet would break!)
Expand Down Expand Up @@ -139,6 +140,7 @@ def test_downloading_simple_ascii(download_to_temp):
assert counter.count == 0, 'Item was re-downloaded.'


@pytest.mark.network
def test_natural_earth_downloader(tmpdir):
# downloads a file to a temporary location, and uses that temporary
# location, then:
Expand Down
5 changes: 4 additions & 1 deletion lib/cartopy/tests/io/test_ogc_clients.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -41,6 +41,7 @@
RESOLUTION = (30, 30)


@pytest.mark.network
@pytest.mark.skipif(not _OWSLIB_AVAILABLE, reason='OWSLib is unavailable.')
class TestWMSRasterSource(object):
URI = 'http://vmap0.tiles.osgeo.org/wms/vmap0'
Expand Down Expand Up @@ -144,6 +145,7 @@ def test_float_resolution(self):
assert img.shape == (40, 20, 4)


@pytest.mark.network
@pytest.mark.skipif(not _OWSLIB_AVAILABLE, reason='OWSLib is unavailable.')
class TestWMTSRasterSource(object):
URI = 'https://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi'
Expand Down Expand Up @@ -217,6 +219,7 @@ def test_fetch_img_reprojected_twoparts(self):
assert im2.extent == extent


@pytest.mark.network
@pytest.mark.skipif(not _OWSLIB_AVAILABLE, reason='OWSLib is unavailable.')
class TestWFSGeometrySource(object):
URI = 'https://nsidc.org/cgi-bin/atlas_south?service=WFS'
Expand Down
5 changes: 3 additions & 2 deletions lib/cartopy/tests/io/test_srtm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -27,7 +27,8 @@
import cartopy.io.srtm


pytestmark = pytest.mark.skip('SRTM login not supported')
pytestmark = [pytest.mark.skip('SRTM login not supported'),
pytest.mark.network]


class TestRetrieve(object):
Expand Down
3 changes: 3 additions & 0 deletions lib/cartopy/tests/mpl/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
setattr(self.parent, self.function_name, self.orig_fn)


@pytest.mark.natural_earth
def test_coastline_loading_cache():
# a5caae040ee11e72a62a53100fe5edc355304419 added coastline caching.
# This test ensures it is working.
Expand All @@ -99,6 +100,7 @@ def test_coastline_loading_cache():
plt.close()


@pytest.mark.natural_earth
def test_shapefile_transform_cache():
# a5caae040ee11e72a62a53100fe5edc355304419 added shapefile mpl
# geometry caching based on geometry object id. This test ensures
Expand Down Expand Up @@ -185,6 +187,7 @@ def test_contourf_transform_path_counting():
plt.close()


@pytest.mark.network
@pytest.mark.skipif(not _OWSLIB_AVAILABLE, reason='OWSLib is unavailable.')
def test_wmts_tile_caching():
image_cache = WMTSRasterSource._shared_image_cache
Expand Down
5 changes: 4 additions & 1 deletion lib/cartopy/tests/mpl/test_crs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2013 - 2017, Met Office
# (C) British Crown Copyright 2013 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand All @@ -18,11 +18,13 @@
from __future__ import (absolute_import, division, print_function)

import matplotlib.pyplot as plt
import pytest

import cartopy.crs as ccrs
from cartopy.tests.mpl import ImageTesting


@pytest.mark.natural_earth
@ImageTesting(['lambert_conformal_south'])
def test_lambert_south():
# Reference image: http://www.icsm.gov.au/mapping/map_projections.html
Expand All @@ -33,6 +35,7 @@ def test_lambert_south():
ax.gridlines()


@pytest.mark.natural_earth
@ImageTesting(['mercator_squashed'])
def test_mercator_squashed():
globe = ccrs.Globe(semimajor_axis=10000, semiminor_axis=9000,
Expand Down
2 changes: 2 additions & 0 deletions lib/cartopy/tests/mpl/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import (absolute_import, division, print_function)

import matplotlib.pyplot as plt
import pytest

from cartopy.tests.mpl import MPL_VERSION, ImageTesting

Expand All @@ -40,6 +41,7 @@ def new_fn(*args, **kwargs):
return new_fn


@pytest.mark.natural_earth
@ExampleImageTesting(['global_map'],
tolerance=4 if MPL_VERSION < '2' else 0)
def test_global_map():
Expand Down
5 changes: 4 additions & 1 deletion lib/cartopy/tests/mpl/test_features.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -27,6 +27,7 @@
from cartopy.tests.mpl import MPL_VERSION, ImageTesting


@pytest.mark.natural_earth
@ImageTesting(['natural_earth'])
def test_natural_earth():
ax = plt.axes(projection=ccrs.PlateCarree())
Expand All @@ -40,6 +41,7 @@ def test_natural_earth():
ax.set_ylim((-40, 40))


@pytest.mark.natural_earth
@ImageTesting(['natural_earth_custom'])
def test_natural_earth_custom():
ax = plt.axes(projection=ccrs.PlateCarree())
Expand All @@ -65,6 +67,7 @@ def test_gshhs():
facecolor='green'), facecolor='blue')


@pytest.mark.network
@pytest.mark.skipif(not _OWSLIB_AVAILABLE, reason='OWSLib is unavailable.')
@ImageTesting(['wfs'])
def test_wfs():
Expand Down
4 changes: 3 additions & 1 deletion lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -33,6 +33,7 @@
from cartopy.tests.mpl import MPL_VERSION, ImageTesting


@pytest.mark.natural_earth
@ImageTesting(['gridliner1'])
def test_gridliner():
ny, nx = 2, 4
Expand Down Expand Up @@ -112,6 +113,7 @@ def test_gridliner_specified_lines():
grid_label_image = 'gridliner_labels_pre_mpl_1.5'


@pytest.mark.natural_earth
@ImageTesting([grid_label_image])
def test_grid_labels():
plt.figure(figsize=(8, 10))
Expand Down
8 changes: 7 additions & 1 deletion lib/cartopy/tests/mpl/test_images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand All @@ -23,6 +23,7 @@
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import pytest
import shapely.geometry as sgeom

from cartopy import config
Expand All @@ -43,6 +44,8 @@
# We have an exceptionally large tolerance for the web_tiles test.
# The basemap changes on a regular basis (for seasons) and we really only
# care that it is putting images onto the map which are roughly correct.
@pytest.mark.natural_earth
@pytest.mark.network
@ImageTesting(['web_tiles'],
tolerance=12 if MPL_VERSION < '2' else 2.9)
def test_web_tiles():
Expand Down Expand Up @@ -78,6 +81,8 @@ def test_web_tiles():
ax.coastlines()


@pytest.mark.natural_earth
@pytest.mark.network
@ImageTesting(['image_merge'],
tolerance=3.6 if MPL_VERSION < '2' else 0)
def test_image_merge():
Expand Down Expand Up @@ -118,6 +123,7 @@ def test_imshow():
extent=[-180, 180, -90, 90])


@pytest.mark.natural_earth
@ImageTesting(['imshow_regional_projected'],
tolerance=10.4 if MPL_VERSION < '2' else 0)
def test_imshow_projected():
Expand Down
3 changes: 2 additions & 1 deletion lib/cartopy/tests/mpl/test_img_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2011 - 2017, Met Office
# (C) British Crown Copyright 2011 - 2018, Met Office
#
# This file is part of cartopy.
#
Expand Down Expand Up @@ -101,6 +101,7 @@ def test_different_dims(self):
regrid_tolerance = 0


@pytest.mark.natural_earth
@ImageTesting(['regrid_image'],
tolerance=regrid_tolerance)
def test_regrid_image():
Expand Down
Loading

0 comments on commit 67e0113

Please sign in to comment.