From 3c05a203e4de5c1345cd10fdc336a9f729b1a633 Mon Sep 17 00:00:00 2001 From: Graham Inggs Date: Mon, 15 Jul 2019 20:57:54 +0200 Subject: [PATCH] Fix tests on big-endian systems (#3125) * Fix tests on big-endian systems * PEP 8 --- xarray/tests/test_dataarray.py | 4 +++- xarray/tests/test_dataset.py | 3 ++- xarray/tests/test_formatting.py | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 63317519bc7..97245395e31 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3140,7 +3140,9 @@ def test_to_and_from_dict(self): expected_no_data = expected.copy() del expected_no_data['data'] del expected_no_data['coords']['x']['data'] - expected_no_data['coords']['x'].update({'dtype': 'U1' + expected_no_data['coords']['x'].update({'dtype': endiantype, + 'shape': (2,)}) expected_no_data.update({'dtype': 'float64', 'shape': (2, 3)}) actual_no_data = array.to_dict(data=False) assert expected_no_data == actual_no_data diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index db7c5a35de6..fc6f7f36938 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -3460,7 +3460,8 @@ def test_to_and_from_dict(self): del expected_no_data['coords']['t']['data'] del expected_no_data['data_vars']['a']['data'] del expected_no_data['data_vars']['b']['data'] - expected_no_data['coords']['t'].update({'dtype': 'U1' + expected_no_data['coords']['t'].update({'dtype': endiantype, 'shape': (10,)}) expected_no_data['data_vars']['a'].update({'dtype': 'float64', 'shape': (10,)}) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 8a3c95a4962..be3e368e02b 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from textwrap import dedent +import sys import numpy as np import pandas as pd @@ -204,6 +205,7 @@ def test_diff_array_repr(self): 'label': ('x', np.array([1, 2], dtype='int64'))}, attrs={'units': 'kg'}) + byteorder = '<' if sys.byteorder == 'little' else '>' expected = dedent("""\ Left and right DataArray objects are not identical Differing dimensions: @@ -215,8 +217,8 @@ def test_diff_array_repr(self): R array([1, 2], dtype=int64) Differing coordinates: - L * x (x) ' expected = dedent("""\ Left and right Dataset objects are not identical Differing dimensions: (x: 2, y: 3) != (x: 2) Differing coordinates: - L * x (x)