Skip to content

Commit 03975b7

Browse files
authored
Converted integration/um to pytest (#6811)
* Converted test_fieldsfile to pytest * added cml * removed old cml dir
1 parent 81a9c27 commit 03975b7

File tree

5 files changed

+113
-152
lines changed

5 files changed

+113
-152
lines changed

lib/iris/tests/integration/um/test_fieldsfile.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,32 @@
44
# See LICENSE in the root of the repository for full licensing details.
55
"""Test the fast loading of structured Fieldsfiles."""
66

7-
# import iris tests first so that some things can be initialised before
8-
# importing anything else
9-
import iris.tests as tests # isort:skip
7+
import pytest
8+
109
from iris.cube import CubeList
1110
from iris.fileformats.um import load_cubes as load
11+
from iris.tests import _shared_utils
1212

1313

14-
@tests.skip_data
15-
class TestStructuredLoadFF(tests.IrisTest):
16-
def setUp(self):
17-
self.fname = tests.get_data_path(("FF", "structured", "small"))
14+
@_shared_utils.skip_data
15+
class TestStructuredLoadFF:
16+
@pytest.fixture(autouse=True)
17+
def _setup(self):
18+
self.fname = _shared_utils.get_data_path(("FF", "structured", "small"))
1819

1920
def _merge_cubes(self, cubes):
2021
# Merge the 2D cubes returned by `iris.fileformats.um.load_cubes`.
2122
return CubeList(cubes).merge_cube()
2223

23-
def test_simple(self):
24+
def test_simple(self, request):
2425
list_of_cubes = list(load(self.fname, None))
2526
cube = self._merge_cubes(list_of_cubes)
26-
self.assertCML(cube)
27+
_shared_utils.assert_CML(request, cube)
2728

28-
def test_simple_callback(self):
29+
def test_simple_callback(self, request):
2930
def callback(cube, field, filename):
3031
cube.attributes["processing"] = "fast-ff"
3132

3233
list_of_cubes = list(load(self.fname, callback=callback))
3334
cube = self._merge_cubes(list_of_cubes)
34-
self.assertCML(cube)
35-
36-
37-
if __name__ == "__main__":
38-
tests.main()
35+
_shared_utils.assert_CML(request, cube)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" ?>
2+
<cubes xmlns="urn:x-iris:cubeml-0.2">
3+
<cube dtype="float32" standard_name="air_pressure" units="Pa">
4+
<attributes>
5+
<attribute name="STASH" value="m01s00i407"/>
6+
<attribute name="source" value="Data from Met Office Unified Model"/>
7+
<attribute name="um_version" value="8.5"/>
8+
</attributes>
9+
<coords>
10+
<coord datadims="[0]">
11+
<dimCoord checksum="0x557d9dd7" id="1d45e087" points="[13681., 13682.]" shape="(2,)" standard_name="forecast_period" units="Unit('hours')" value_type="float64"/>
12+
</coord>
13+
<coord>
14+
<dimCoord checksum="0x5c599900" id="9c8bdf81" points="[182880.]" shape="(1,)" standard_name="forecast_reference_time" units="Unit('hours since 1970-01-01 00:00:00', calendar='360_day')" value_type="float64"/>
15+
</coord>
16+
<coord datadims="[2]">
17+
<dimCoord checksum="0x603fcd68" id="77a50eb5" points="[-43.2421875, -43.0078125, -42.7734375, ..., -36.9140625, -36.6796875, -36.4453125]" shape="(30,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
18+
<geogCS earth_radius="6371229.0"/>
19+
</dimCoord>
20+
</coord>
21+
<coord datadims="[1]">
22+
<dimCoord bounds="[0., 10.0000001, 10.0000001, 26.66666665, 26.66666665, 49.99999965]" checksum="0x2a3c671a" id="fb105c19" long_name="level_height" points="[4.99999997, 18.33333295, 38.33333315]" shape="(3,)" units="Unit('m')" value_type="float64">
23+
<attributes>
24+
<attribute name="positive" value="up"/>
25+
</attributes>
26+
</dimCoord>
27+
</coord>
28+
<coord datadims="[3]">
29+
<dimCoord checksum="0xe39c60bc" id="f913a8b3" points="[70.13671875, 70.48828125, 70.83984375, ..., 83.14453125, 83.49609375, 83.84765625]" shape="(40,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
30+
<geogCS earth_radius="6371229.0"/>
31+
</dimCoord>
32+
</coord>
33+
<coord datadims="[1]">
34+
<dimCoord checksum="0x2bcb8d87" id="38fd0305" points="[1, 2, 3]" shape="(3,)" standard_name="model_level_number" units="Unit('1')" value_type="int64">
35+
<attributes>
36+
<attribute name="positive" value="up"/>
37+
</attributes>
38+
</dimCoord>
39+
</coord>
40+
<coord datadims="[1]">
41+
<dimCoord bounds="[1., 0.99887003, 0.99887003, 0.99698817, 0.99698817, 0.99435654]" checksum="0x0022c1b5" id="a5c170db" long_name="sigma" points="[0.99943494, 0.99792888, 0.99567192]" shape="(3,)" units="Unit('1')" value_type="float64"/>
42+
</coord>
43+
<coord datadims="[0]">
44+
<dimCoord checksum="0x36704aa3" id="cb784457" points="[196561., 196562.]" shape="(2,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='360_day')" value_type="float64"/>
45+
</coord>
46+
</coords>
47+
<cellMethods/>
48+
<data checksum="0x42a6d5c8" dtype="float32" shape="(2, 3, 30, 40)"/>
49+
</cube>
50+
</cubes>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" ?>
2+
<cubes xmlns="urn:x-iris:cubeml-0.2">
3+
<cube dtype="float32" standard_name="air_pressure" units="Pa">
4+
<attributes>
5+
<attribute name="STASH" value="m01s00i407"/>
6+
<attribute name="processing" value="fast-ff"/>
7+
<attribute name="source" value="Data from Met Office Unified Model"/>
8+
<attribute name="um_version" value="8.5"/>
9+
</attributes>
10+
<coords>
11+
<coord datadims="[0]">
12+
<dimCoord checksum="0x557d9dd7" id="1d45e087" points="[13681., 13682.]" shape="(2,)" standard_name="forecast_period" units="Unit('hours')" value_type="float64"/>
13+
</coord>
14+
<coord>
15+
<dimCoord checksum="0x5c599900" id="9c8bdf81" points="[182880.]" shape="(1,)" standard_name="forecast_reference_time" units="Unit('hours since 1970-01-01 00:00:00', calendar='360_day')" value_type="float64"/>
16+
</coord>
17+
<coord datadims="[2]">
18+
<dimCoord checksum="0x603fcd68" id="77a50eb5" points="[-43.2421875, -43.0078125, -42.7734375, ..., -36.9140625, -36.6796875, -36.4453125]" shape="(30,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
19+
<geogCS earth_radius="6371229.0"/>
20+
</dimCoord>
21+
</coord>
22+
<coord datadims="[1]">
23+
<dimCoord bounds="[0., 10.0000001, 10.0000001, 26.66666665, 26.66666665, 49.99999965]" checksum="0x2a3c671a" id="fb105c19" long_name="level_height" points="[4.99999997, 18.33333295, 38.33333315]" shape="(3,)" units="Unit('m')" value_type="float64">
24+
<attributes>
25+
<attribute name="positive" value="up"/>
26+
</attributes>
27+
</dimCoord>
28+
</coord>
29+
<coord datadims="[3]">
30+
<dimCoord checksum="0xe39c60bc" id="f913a8b3" points="[70.13671875, 70.48828125, 70.83984375, ..., 83.14453125, 83.49609375, 83.84765625]" shape="(40,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
31+
<geogCS earth_radius="6371229.0"/>
32+
</dimCoord>
33+
</coord>
34+
<coord datadims="[1]">
35+
<dimCoord checksum="0x2bcb8d87" id="38fd0305" points="[1, 2, 3]" shape="(3,)" standard_name="model_level_number" units="Unit('1')" value_type="int64">
36+
<attributes>
37+
<attribute name="positive" value="up"/>
38+
</attributes>
39+
</dimCoord>
40+
</coord>
41+
<coord datadims="[1]">
42+
<dimCoord bounds="[1., 0.99887003, 0.99887003, 0.99698817, 0.99698817, 0.99435654]" checksum="0x0022c1b5" id="a5c170db" long_name="sigma" points="[0.99943494, 0.99792888, 0.99567192]" shape="(3,)" units="Unit('1')" value_type="float64"/>
43+
</coord>
44+
<coord datadims="[0]">
45+
<dimCoord checksum="0x36704aa3" id="cb784457" points="[196561., 196562.]" shape="(2,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='360_day')" value_type="float64"/>
46+
</coord>
47+
</coords>
48+
<cellMethods/>
49+
<data checksum="0x42a6d5c8" dtype="float32" shape="(2, 3, 30, 40)"/>
50+
</cube>
51+
</cubes>

lib/iris/tests/results/integration/um/fieldsfile/TestStructuredLoadFF/simple.cml

Lines changed: 0 additions & 68 deletions
This file was deleted.

lib/iris/tests/results/integration/um/fieldsfile/TestStructuredLoadFF/simple_callback.cml

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)