Skip to content

Commit

Permalink
Merge pull request #176 from sadielbartholomew/print-no-data-other-co…
Browse files Browse the repository at this point in the history
…nstructs

Add inspection testing covering any construct lacking data
  • Loading branch information
sadielbartholomew authored Mar 2, 2022
2 parents 76d2102 + d7fc3b9 commit bb23013
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cfdm/test/test_Domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ def test_Domain__repr__str__dump(self):
for title in (None, "title"):
d.dump(display=False, _title=title)

# Test when dimension coordinate has no data
# Test when any construct which can have data in fact has no data.
d = d.copy()
t = d.construct("time")
t.del_data()
self.assertFalse(t.has_data())
str(d)
for identity in [
"time", # a dimension coordinate
"latitude", # an auxiliary coordinate
"measure:area", # a cell measure
"surface_altitude", # a domain ancillary
]:
c = d.construct(identity) # get relevant construct, type as above
c.del_data()
self.assertFalse(c.has_data())
str(d)
repr(d)

def test_Domain__init__(self):
"""Test the Domain constructor and source keyword."""
Expand Down
15 changes: 15 additions & 0 deletions cfdm/test/test_Field.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ def test_Field__repr__str__dump_construct_type(self):
self.assertIsInstance(f.dump(display=False), str)
self.assertEqual(f.construct_type, "field")

# Test when any construct which can have data in fact has no data.
f = f.copy()
for identity in [
"time", # a dimension coordinate
"latitude", # an auxiliary coordinate
"measure:area", # a cell measure
"surface_altitude", # a domain ancillary,
"air_temperature standard_error", # a field ancillary
]:
c = f.construct(identity) # get relevant construct, type as above
c.del_data()
self.assertFalse(c.has_data())
str(f)
repr(f)

def test_Field__init__(self):
"""Test the Field constructor and source keyword."""
cfdm.Field(source="qwerty")
Expand Down

0 comments on commit bb23013

Please sign in to comment.