-
Notifications
You must be signed in to change notification settings - Fork 297
Test wrangling vs v3.0.x #4249
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
Test wrangling vs v3.0.x #4249
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
|
||
|
||
class SystemInitialTest(tests.IrisTest): | ||
def system_test_supported_filetypes(self): | ||
def test_supported_filetypes(self): | ||
nx, ny = 60, 60 | ||
data = np.arange(nx * ny, dtype=">f4").reshape(nx, ny) | ||
|
||
|
@@ -74,7 +74,7 @@ def horiz_cs(): | |
new_cube, ("system", "supported_filetype_%s.cml" % filetype) | ||
) | ||
|
||
def system_test_imports_general(self): | ||
def test_imports_general(self): | ||
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.
|
||
if tests.MPL_AVAILABLE: | ||
import matplotlib # noqa | ||
import netCDF4 # noqa | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
import iris.tests.stock | ||
|
||
|
||
class TestMixin: | ||
class MergeMixin: | ||
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.
|
||
""" | ||
Mix-in class for attributes & utilities common to these test cases. | ||
|
||
|
@@ -55,15 +55,15 @@ def test_duplication(self): | |
|
||
|
||
@tests.skip_data | ||
class TestSingleCube(tests.IrisTest, TestMixin): | ||
class TestSingleCube(tests.IrisTest, MergeMixin): | ||
def setUp(self): | ||
self._data_path = tests.get_data_path(("PP", "globClim1", "theta.pp")) | ||
self._num_cubes = 1 | ||
self._prefix = "theta" | ||
|
||
|
||
@tests.skip_data | ||
class TestMultiCube(tests.IrisTest, TestMixin): | ||
class TestMultiCube(tests.IrisTest, MergeMixin): | ||
def setUp(self): | ||
self._data_path = tests.get_data_path( | ||
("PP", "globClim1", "dec_subset.pp") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the LGPL license. | ||
# See COPYING and COPYING.LESSER in the root of the repository for full | ||
# licensing details. | ||
"""Unit tests for the :mod:`iris.analysis.scipy_interpolate` module.""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the LGPL license. | ||
# See COPYING and COPYING.LESSER in the root of the repository for full | ||
# licensing details. | ||
"""Unit tests for the :mod:`iris.time` module.""" |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -224,12 +224,12 @@ def setUp(self): | |||||||||||||
self.expected_value = EQ_EXPECTATIONS | ||||||||||||||
|
||||||||||||||
def test_cftime_equal(self): | ||||||||||||||
pdt = PartialDateTime(month=3, microsecond=2) | ||||||||||||||
pdt = PartialDateTime(month=3, second=2) | ||||||||||||||
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. This was failing because the equality operator returned Lines 152 to 157 in a6cd220
My guess is that, when this test was written, |
||||||||||||||
other = cftime.datetime(year=2013, month=3, day=20, second=2) | ||||||||||||||
self.assertTrue(pdt == other) | ||||||||||||||
|
||||||||||||||
def test_cftime_not_equal(self): | ||||||||||||||
pdt = PartialDateTime(month=3, microsecond=2) | ||||||||||||||
pdt = PartialDateTime(month=3, second=2) | ||||||||||||||
other = cftime.datetime(year=2013, month=4, day=20, second=2) | ||||||||||||||
self.assertFalse(pdt == other) | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -155,23 +155,21 @@ def __eq__(self, other): | |||||||||||
other_attr = other.microsecond | ||||||||||||
if attr is not None and attr != other_attr: | ||||||||||||
result = False | ||||||||||||
|
||||||||||||
except AttributeError: | ||||||||||||
result = NotImplemented | ||||||||||||
result = other.__eq__(self) | ||||||||||||
if result is NotImplemented: | ||||||||||||
# Equality is undefined between these objects. We don't | ||||||||||||
# want Python to fall back to the default `object` | ||||||||||||
# behaviour (which compares using object IDs), so we raise | ||||||||||||
# an exception here instead. | ||||||||||||
fmt = "unable to compare PartialDateTime with {}" | ||||||||||||
raise TypeError(fmt.format(type(other))) | ||||||||||||
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. One test compares a iris/lib/iris/tests/unit/time/test_PartialDateTime.py Lines 66 to 70 in 1505995
It was getting We previously used the My above solution works, but feels like a bit of a hack. Alternative solutions welcome! 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. @rcomer Rings a bell... see Unidata/cftime#81 😉 This might explain this change in behaviour, which was kinda 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. @bjlittle yup the failures I saw were just for 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. @rcomer Okay, I'm fine with this. It seems completely reasonable to me and maintains prior behaviour both within |
||||||||||||
|
||||||||||||
return result | ||||||||||||
|
||||||||||||
def __ne__(self, other): | ||||||||||||
result = self.__eq__(other) | ||||||||||||
if result is not NotImplemented: | ||||||||||||
result = not result | ||||||||||||
return result | ||||||||||||
|
||||||||||||
def __cmp__(self, other): | ||||||||||||
# Since we've defined all the rich comparison operators (via | ||||||||||||
# functools.total_ordering), we can only reach this point if | ||||||||||||
# neither this class nor the other class had a rich comparison | ||||||||||||
# that could handle the type combination. | ||||||||||||
# We don't want Python to fall back to the default `object` | ||||||||||||
# behaviour (which compares using object IDs), so we raise an | ||||||||||||
# exception here instead. | ||||||||||||
fmt = "unable to compare PartialDateTime with {}" | ||||||||||||
raise TypeError(fmt.format(type(other))) |
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.
pytest
requires test names to start with "test" or it just won't discover them.