Skip to content

Commit f5884a2

Browse files
authored
Minor tests improvements (#7113)
* fix coverage config * assert and silence some UserWarnings from indexes
1 parent 341f130 commit f5884a2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ requires = [
1010
fallback_version = "999"
1111

1212
[tool.coverage.run]
13-
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]
1413
omit = [
1514
"*/xarray/tests/*",
1615
"*/xarray/core/dask_array_compat.py",
@@ -20,3 +19,6 @@ omit = [
2019
"*/xarray/core/types.py",
2120
]
2221
source = ["xarray"]
22+
23+
[tool.coverage.report]
24+
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]

xarray/tests/test_dataset.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,8 @@ def test_rename_old_name(self) -> None:
28752875
def test_rename_same_name(self) -> None:
28762876
data = create_test_data()
28772877
newnames = {"var1": "var1", "dim2": "dim2"}
2878-
renamed = data.rename(newnames)
2878+
with pytest.warns(UserWarning, match="does not create an index anymore"):
2879+
renamed = data.rename(newnames)
28792880
assert_identical(renamed, data)
28802881

28812882
def test_rename_dims(self) -> None:
@@ -2954,11 +2955,16 @@ def test_rename_multiindex(self) -> None:
29542955
assert_identical(expected, actual)
29552956

29562957
with pytest.raises(ValueError, match=r"'a' conflicts"):
2957-
original.rename({"x": "a"})
2958+
with pytest.warns(UserWarning, match="does not create an index anymore"):
2959+
original.rename({"x": "a"})
2960+
29582961
with pytest.raises(ValueError, match=r"'x' conflicts"):
2959-
original.rename({"a": "x"})
2962+
with pytest.warns(UserWarning, match="does not create an index anymore"):
2963+
original.rename({"a": "x"})
2964+
29602965
with pytest.raises(ValueError, match=r"'b' conflicts"):
2961-
original.rename({"a": "b"})
2966+
with pytest.warns(UserWarning, match="does not create an index anymore"):
2967+
original.rename({"a": "b"})
29622968

29632969
def test_rename_perserve_attrs_encoding(self) -> None:
29642970
# test propagate attrs/encoding to new variable(s) created from Index object

0 commit comments

Comments
 (0)