diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index a5312abb1a1..1ee6c86d064 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -475,14 +475,14 @@ def test_array_repr(self) -> None: if ON_WINDOWS: expected = dedent( """\ - Size: 8B + Size: 4B array([0]) Dimensions without coordinates: test""" ) else: expected = dedent( """\ - Size: 4B + Size: 8B array([0]) Dimensions without coordinates: test""" ) @@ -499,12 +499,21 @@ def test_array_repr(self) -> None: with xr.set_options(display_expand_data=False): actual = formatting.array_repr(ds[(1, 2)]) - expected = dedent( - """\ - Size: 8B - 0 - Dimensions without coordinates: test""" - ) + if ON_WINDOWS: + expected = dedent( + """\ + Size: 4B + 0 + Dimensions without coordinates: test""" + ) + + else: + expected = dedent( + """\ + Size: 8B + 0 + Dimensions without coordinates: test""" + ) assert actual == expected @@ -718,8 +727,9 @@ def test__mapping_repr(display_max_rows, n_vars, n_attr) -> None: dims_values = formatting.dim_summary_limited( ds, col_width=col_width + 1, max_rows=display_max_rows ) + expected_size = "640B" if ON_WINDOWS else "1kB" expected = f"""\ - Size: 1kB + Size: {expected_size} {dims_start}({dims_values}) Coordinates: ({n_vars}) Data variables: ({n_vars}) diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index e15de077900..f2754d26483 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -1,5 +1,6 @@ from __future__ import annotations +import sys import warnings from abc import ABC from copy import copy, deepcopy @@ -58,6 +59,8 @@ [{"x": (3, 1), "z": 2}, ((3, 1), (0, 0), (2, 2))], ] +ON_WINDOWS = sys.platform == "win32" + @pytest.fixture def var(): @@ -1228,15 +1231,26 @@ def test_as_variable(self): def test_repr(self): v = Variable(["time", "x"], [[1, 2, 3], [4, 5, 6]], {"foo": "bar"}) - expected = dedent( + if ON_WINDOWS: + expected = dedent( + """ + Size: 24B + array([[1, 2, 3], + [4, 5, 6]]) + Attributes: + foo: bar """ - Size: 48B - array([[1, 2, 3], - [4, 5, 6]]) - Attributes: - foo: bar - """ - ).strip() + ).strip() + else: + expected = dedent( + """ + Size: 48B + array([[1, 2, 3], + [4, 5, 6]]) + Attributes: + foo: bar + """ + ).strip() assert expected == repr(v) def test_repr_lazy_data(self):