Skip to content

Commit 5551121

Browse files
Add minimal unit test for Field.del_construct
1 parent a503be3 commit 5551121

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cf/test/test_Field.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,30 @@ def test_Field_set_construct_conform(self):
25722572
cm2 = f.cell_method("method:maximum")
25732573
self.assertEqual(cm2.get_axes(), ("T",))
25742574

2575+
def test_Field_del_construct(self):
2576+
"""Test the `del_construct` Field method."""
2577+
# Test a field without cyclic axes. These are equivalent tests to those
2578+
# in the cfdm test suite, to check the behaviour is the same in cf.
2579+
f = self.f1.copy()
2580+
print(f.cyclic())
2581+
2582+
self.assertIsInstance(
2583+
f.del_construct("auxiliarycoordinate1"), cf.AuxiliaryCoordinate
2584+
)
2585+
2586+
with self.assertRaises(ValueError):
2587+
f.del_construct("auxiliarycoordinate1")
2588+
2589+
self.assertIsNone(
2590+
f.del_construct("auxiliarycoordinate1", default=None)
2591+
)
2592+
2593+
self.assertIsInstance(
2594+
f.del_construct("measure:area"), cf.CellMeasure
2595+
)
2596+
2597+
# TODO test cyclic nature
2598+
25752599
def test_Field_persist(self):
25762600
"""Test the `persist` Field method."""
25772601
f = cf.example_field(0)

0 commit comments

Comments
 (0)