diff --git a/test/test_cattrs.py b/test/test_cattrs.py index 5d96f90..68f6747 100644 --- a/test/test_cattrs.py +++ b/test/test_cattrs.py @@ -58,3 +58,19 @@ def test_unstructure_xarray_tree_to_ascii(): # The whole string will be in memory when doing this, # duplicating the data. assert f_dict == "1 2 3" + + +def test_unstructure_xarray_tree(): + x_arr = xr.DataArray([1, 2, 3]) + x_set = xr.Dataset({"x": x_arr}) + x_tree = xr.DataTree(x_set) + f = Baz(x=x_tree) + + converter = Converter() + converter.register_unstructure_hook(xr.DataTree, lambda v: v) + f_dict = converter.unstructure(f) + + # We expect that the default unstructure functionality keeps + # the xarray as is. + # This helps when finally converting the dictionary to MF6 input files. + assert x_tree is f_dict["x"]