def test_combine_nested_combine_attrs_variables(
        self, combine_attrs, attrs1, attrs2, expected_attrs, expect_exception
    ):
        """check that combine_attrs is used on data variables and coords"""
        data1 = Dataset(
            {
                "a": ("x", [1, 2], attrs1),
                "b": ("x", [3, -1], attrs1),
                "x": ("x", [0, 1], attrs1),
            }
        )
        data2 = Dataset(
            {
                "a": ("x", [2, 3], attrs2),
                "b": ("x", [-2, 1], attrs2),
                "x": ("x", [2, 3], attrs2),
            }
        )

        if expect_exception:
            with pytest.raises(MergeError, match="combine_attrs"):
                combine_by_coords([data1, data2], combine_attrs=combine_attrs)
        else:
            actual = combine_by_coords([data1, data2], combine_attrs=combine_attrs)
            expected = Dataset(
                {
                    "a": ("x", [1, 2, 2, 3], expected_attrs),
                    "b": ("x", [3, -1, -2, 1], expected_attrs),
                },
                {"x": ("x", [0, 1, 2, 3], expected_attrs)},
            )

            assert_identical(actual, expected)
check that combine_attrs is used on data variables and coords
xarray/tests/test_combine.py