Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import sys

import cartopy
from distutils.version import LooseVersion
import matplotlib
import owslib
from packaging.version import parse as parse_version
from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -84,7 +84,7 @@


if (hasattr(owslib, '__version__') and
LooseVersion(owslib.__version__) >= '0.19.2'):
parse_version(owslib.__version__) >= parse_version('0.19.2')):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly annoying that we have to wrap everything ourselves now, rather than "parse_version" being able to cast the string to Version internally during the comparison...

expected_failing_examples = []
else:
# OWSLib WMTS support is broken.
Expand Down
7 changes: 4 additions & 3 deletions lib/cartopy/tests/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# licensing details.

import base64
from distutils.version import LooseVersion
import os
import glob
import shutil
Expand All @@ -17,8 +16,10 @@
import matplotlib.patches as mpatches
from matplotlib.testing import setup as mpl_setup
import matplotlib.testing.compare as mcompare
import packaging.version

MPL_VERSION = LooseVersion(mpl.__version__)

MPL_VERSION = packaging.version.parse(mpl.__version__)


class ImageTesting:
Expand Down Expand Up @@ -200,7 +201,7 @@ def wrapped(*args, **kwargs):
plt.close('all')

with mpl.style.context(self.style):
if MPL_VERSION >= '3.2.0':
if MPL_VERSION >= packaging.version.parse('3.2.0'):
mpl.rcParams['text.kerning_factor'] = 6

r = test_func(*args, **kwargs)
Expand Down
5 changes: 4 additions & 1 deletion lib/cartopy/tests/mpl/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# licensing details.

import matplotlib.pyplot as plt
from packaging.version import parse as parse_version
import pytest

import cartopy.crs as ccrs
Expand Down Expand Up @@ -49,7 +50,9 @@ def test_global_map():

@pytest.mark.natural_earth
@ExampleImageTesting(['contour_label'],
tolerance=9.9 if MPL_VERSION < "3.2" else 0.5)
tolerance=(9.9
if MPL_VERSION < parse_version("3.2")
else 0.5))
def test_contour_label():
from cartopy.tests.mpl.test_caching import sample_data
fig = plt.figure()
Expand Down
7 changes: 4 additions & 3 deletions lib/cartopy/tests/mpl/test_mpl_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy as np
import matplotlib.pyplot as plt
from packaging.version import parse as parse_version
import pytest

import cartopy.crs as ccrs
Expand Down Expand Up @@ -106,7 +107,7 @@ def test_global_scatter_wrap_no_transform():

@pytest.mark.natural_earth
@ImageTesting(['global_hexbin_wrap'],
tolerance=2 if MPL_VERSION < '3.2' else 0.5)
tolerance=2 if MPL_VERSION < parse_version('3.2') else 0.5)
def test_global_hexbin_wrap():
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(zorder=2)
Expand All @@ -123,7 +124,7 @@ def test_global_hexbin_wrap():

@pytest.mark.natural_earth
@ImageTesting(['global_hexbin_wrap'],
tolerance=2 if MPL_VERSION < '3.2' else 0.5)
tolerance=2 if MPL_VERSION < parse_version('3.2') else 0.5)
def test_global_hexbin_wrap_transform():
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(zorder=2)
Expand Down Expand Up @@ -827,7 +828,7 @@ def test_barbs_1d_transformed():

@pytest.mark.natural_earth
@ImageTesting(['streamplot'], style='mpl20',
tolerance=42 if MPL_VERSION < "3.2" else 0.54)
tolerance=42 if MPL_VERSION < parse_version('3.2') else 0.54)
def test_streamplot():
x = np.arange(-60, 42.5, 2.5)
y = np.arange(30, 72.5, 2.5)
Expand Down
1 change: 1 addition & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flufl.lock
packaging>=20
pytest>=5.1.2