Skip to content

Commit

Permalink
Test attribute value assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Jan 15, 2025
1 parent 9dcb65e commit 7eb0d27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/core/test_NcAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,17 @@ def test_eq_onestring_arrayofonestring(self):
assert attr1.value.dtype == "<U4"

# NOTE: **not** testing a vector of multiple strings, since this has no function at present


class Test_NcAttribute__value_assign:
def test_set(self, datatype, structuretype):
attr = NcAttribute("x", None)

set_value = attrvalue(datatype, structuretype)
attr.value = set_value

expected_array = np.asanyarray(set_value)
assert isinstance(attr.value, np.ndarray)
assert attr.value.dtype == expected_array.dtype
assert attr.value.shape == expected_array.shape
assert np.all(attr.value == expected_array)

0 comments on commit 7eb0d27

Please sign in to comment.