Skip to content

Commit

Permalink
Shorten cube iterator tests (SciTools#6041)
Browse files Browse the repository at this point in the history
* Shorten cube iterator tests

* Small improvements and whatsnew
  • Loading branch information
bouweandela authored Jul 9, 2024
1 parent 2b2a86a commit 1115fa4
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 122 deletions.
1 change: 1 addition & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ This document explains the changes made to Iris for this release
benchmark historic commits (especially older Python versions).
(:pull:`5963`)

#. `@bouweandela`_ made some tests for :func:`~iris.iterate.izip` faster. (:pull:`6041`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand Down
25 changes: 25 additions & 0 deletions lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ def assert_masked_array_almost_equal(a, b, decimal=6, strict=False):
)


def assert_cml(cubes, reference_filename=None, checksum=True):
"""Test that the CML for the given cubes matches the contents of
the reference file.
If the environment variable IRIS_TEST_CREATE_MISSING is
non-empty, the reference file is created if it doesn't exist.
Parameters
----------
cubes :
Either a Cube or a sequence of Cubes.
reference_filename : optional, default=None
The relative path (relative to the test results directory).
If omitted, the result is generated from the calling
method's name, class, and module using
:meth:`iris.tests.IrisTest.result_path`.
checksum : bool, optional
When True, causes the CML to include a checksum for each
Cube's data. Defaults to True.
"""
test = IrisTest()
test.assertCML(cubes, reference_filename, checksum)


class IrisTest(unittest.TestCase):
"""A subclass of unittest.TestCase which provides Iris specific testing functionality."""

Expand Down
Loading

0 comments on commit 1115fa4

Please sign in to comment.