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

Remove Resolve test workaround #5267

Merged
merged 1 commit into from
Apr 21, 2023
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
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ This document explains the changes made to Iris for this release
of assets bundled within a ``sdist`` and binary ``wheel`` of our
`scitools-iris`_ PyPI package. (:pull:`5259`)

#. `@rcomer`_ removed a now redundant copying workaround from Resolve testing.
(:pull:`5267`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
Expand Down
26 changes: 6 additions & 20 deletions lib/iris/tests/unit/common/resolve/test_Resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,20 +825,6 @@ def setUp(self):
),
]

def _copy(self, items):
# Due to a bug in python 3.6.x, performing a deepcopy of a mock.sentinel
# will yield an object that is not equivalent to its parent, so this
# is a work-around until we drop support for python 3.6.x.
import sys

version = sys.version_info
major, minor = version.major, version.minor
result = deepcopy(items)
if major == 3 and minor <= 6:
for i, item in enumerate(items):
result[i] = result[i]._replace(metadata=item.metadata)
return result

def test_no_mapping(self):
result = Resolve._aux_mapping(self.src_coverage, self.tgt_coverage)
self.assertEqual(dict(), result)
Expand All @@ -852,7 +838,7 @@ def test_full_mapping(self):

def test_transpose_mapping(self):
self.src_coverage.common_items_aux.extend(self.items)
items = self._copy(self.items)
items = deepcopy(self.items)
items[0].dims[0] = 2
items[2].dims[0] = 0
self.tgt_coverage.common_items_aux.extend(items)
Expand All @@ -863,7 +849,7 @@ def test_transpose_mapping(self):
def test_partial_mapping__transposed(self):
_ = self.items.pop(1)
self.src_coverage.common_items_aux.extend(self.items)
items = self._copy(self.items)
items = deepcopy(self.items)
items[0].dims[0] = 2
items[1].dims[0] = 0
self.tgt_coverage.common_items_aux.extend(items)
Expand All @@ -872,7 +858,7 @@ def test_partial_mapping__transposed(self):
self.assertEqual(expected, result)

def test_mapping__match_multiple_src_metadata(self):
items = self._copy(self.items)
items = deepcopy(self.items)
_ = self.items.pop(1)
self.src_coverage.common_items_aux.extend(self.items)
items[1] = items[0]
Expand All @@ -882,7 +868,7 @@ def test_mapping__match_multiple_src_metadata(self):
self.assertEqual(expected, result)

def test_mapping__skip_match_multiple_src_metadata(self):
items = self._copy(self.items)
items = deepcopy(self.items)
_ = self.items.pop(1)
self.tgt_coverage.common_items_aux.extend(self.items)
items[1] = items[0]._replace(dims=[1])
Expand All @@ -892,7 +878,7 @@ def test_mapping__skip_match_multiple_src_metadata(self):
self.assertEqual(expected, result)

def test_mapping__skip_different_rank(self):
items = self._copy(self.items)
items = deepcopy(self.items)
self.src_coverage.common_items_aux.extend(self.items)
items[2] = items[2]._replace(dims=[1, 2])
self.tgt_coverage.common_items_aux.extend(items)
Expand All @@ -902,7 +888,7 @@ def test_mapping__skip_different_rank(self):

def test_bad_metadata_mapping(self):
self.src_coverage.common_items_aux.extend(self.items)
items = self._copy(self.items)
items = deepcopy(self.items)
items[0] = items[0]._replace(metadata=sentinel.bad)
self.tgt_coverage.common_items_aux.extend(items)
emsg = "Failed to map common aux coordinate metadata"
Expand Down