Skip to content

Commit e530907

Browse files
committed
Make the new tests more explicit
1 parent 84c25d3 commit e530907

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

xarray/tests/test_dataarray.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,9 +1703,18 @@ def should_add_coord_to_array(self, name, var, dims):
17031703
assert "x_bnds" not in actual.dims
17041704

17051705
def test_assign_coords_uses_base_variable_class(self) -> None:
1706-
a = DataArray([0, 1, 2], dims=["x"], coords={"x": [0, 1, 2]})
1706+
a = DataArray([0, 1, 3], dims=["x"], coords={"x": [0, 1, 2]})
17071707
a = a.assign_coords(foo=a.x)
1708-
_assert_internal_invariants(a, check_default_indexes=True)
1708+
1709+
# explicit check
1710+
assert isinstance(a["x"].variable, IndexVariable)
1711+
assert not isinstance(a["foo"].variable, IndexVariable)
1712+
1713+
# test internal invariant checks when comparing the datasets
1714+
expected = DataArray(
1715+
[0, 1, 3], dims=["x"], coords={"x": [0, 1, 2], "foo": ("x", [0, 1, 2])}
1716+
)
1717+
assert_identical(a, expected)
17091718

17101719
def test_coords_alignment(self) -> None:
17111720
lhs = DataArray([1, 2, 3], [("x", [0, 1, 2])])

xarray/tests/test_dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,13 +4784,13 @@ def test_setitem_using_list_errors(self, var_list, data, error_regex) -> None:
47844784
def test_setitem_uses_base_variable_class_even_for_index_variables(self) -> None:
47854785
ds = Dataset(coords={"x": [1, 2, 3]})
47864786
ds["y"] = ds["x"]
4787-
4787+
47884788
# explicit check
4789-
assert isintance(ds["x"].variable, IndexVariable)
4789+
assert isinstance(ds["x"].variable, IndexVariable)
47904790
assert not isinstance(ds["y"].variable, IndexVariable)
4791-
4791+
47924792
# test internal invariant checks when comparing the datasets
4793-
expected = Dataset(coords={"x": [1, 2, 3], "y": ("x", [1, 2, 3])})
4793+
expected = Dataset(data_vars={"y": ("x", [1, 2, 3])}, coords={"x": [1, 2, 3]})
47944794
assert_identical(ds, expected)
47954795

47964796
def test_assign(self) -> None:

0 commit comments

Comments
 (0)