Skip to content

Commit

Permalink
Conditional Windows testing
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneschalk committed Feb 6, 2024
1 parent e724825 commit e2db82a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
28 changes: 19 additions & 9 deletions xarray/tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,14 @@ def test_array_repr(self) -> None:
if ON_WINDOWS:
expected = dedent(
"""\
<xarray.DataArray (1, 2) (test: 1)> Size: 8B
<xarray.DataArray (1, 2) (test: 1)> Size: 4B
array([0])
Dimensions without coordinates: test"""
)
else:
expected = dedent(
"""\
<xarray.DataArray (1, 2) (test: 1)> Size: 4B
<xarray.DataArray (1, 2) (test: 1)> Size: 8B
array([0])
Dimensions without coordinates: test"""
)
Expand All @@ -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(
"""\
<xarray.DataArray (1, 2) (test: 1)> Size: 8B
0
Dimensions without coordinates: test"""
)
if ON_WINDOWS:
expected = dedent(
"""\
<xarray.DataArray (1, 2) (test: 1)> Size: 4B
0
Dimensions without coordinates: test"""
)

else:
expected = dedent(
"""\
<xarray.DataArray (1, 2) (test: 1)> Size: 8B
0
Dimensions without coordinates: test"""
)

assert actual == expected

Expand Down Expand Up @@ -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"""\
<xarray.Dataset> Size: 1kB
<xarray.Dataset> Size: {expected_size}
{dims_start}({dims_values})
Coordinates: ({n_vars})
Data variables: ({n_vars})
Expand Down
30 changes: 22 additions & 8 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
import warnings
from abc import ABC
from copy import copy, deepcopy
Expand Down Expand Up @@ -58,6 +59,8 @@
[{"x": (3, 1), "z": 2}, ((3, 1), (0, 0), (2, 2))],
]

ON_WINDOWS = sys.platform == "win32"


@pytest.fixture
def var():
Expand Down Expand Up @@ -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(
"""
<xarray.Variable (time: 2, x: 3)> Size: 24B
array([[1, 2, 3],
[4, 5, 6]])
Attributes:
foo: bar
"""
<xarray.Variable (time: 2, x: 3)> Size: 48B
array([[1, 2, 3],
[4, 5, 6]])
Attributes:
foo: bar
"""
).strip()
).strip()
else:
expected = dedent(
"""
<xarray.Variable (time: 2, x: 3)> Size: 48B
array([[1, 2, 3],
[4, 5, 6]])
Attributes:
foo: bar
"""
).strip()
assert expected == repr(v)

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.9 bare-minimum

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.10 all-but-dask

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.9 min-all-deps

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.12

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.9

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.10 flaky

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

Check failure on line 1254 in xarray/tests/test_variable.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest py3.11

TestVariable.test_repr AssertionError: assert '<xarray.Vari...foo: bar' == '<xarray.Vari...foo: bar' Skipping 56 identical leading characters in diff, use -v to show , 3], - [4, 5, 6]]) ? --- + [4, 5, 6]]) Attributes: foo: bar

def test_repr_lazy_data(self):
Expand Down

0 comments on commit e2db82a

Please sign in to comment.