def test_open_datatree(self, url=unaligned_datatree_url) -> None:
        """Test if `open_datatree` fails to open a netCDF4 with an unaligned group hierarchy."""

        with pytest.raises(
            ValueError,
            match=(
                re.escape(
                    "group '/Group1/subgroup1' is not aligned with its parents:\nGroup:\n"
                )
                + ".*"
            ),
        ):
            open_datatree(url, engine=self.engine)
Test if `open_datatree` fails to open a netCDF4 with an unaligned group hierarchy.
xarray/tests/test_backends_datatree.py