test: Strip whitespace when comparing numpy dtypes for 1.22 compat (#3682)

* test: Strip whitespace when comparing numpy dtypes for 1.22 compat

Strip whitespace when comparing numpy dtype str() in order to preserve
test compatibility with both numpy 1.22 and older versions whose output
differ by whitespace.

Fixes #3680

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Michał Górny 2022-02-03 18:29:46 +01:00 committed by GitHub
parent ffa346860b
commit 1d3b04e805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,7 @@ def test_dtype(simple_dtype):
e = "<" if byteorder == "little" else ">"
assert m.print_dtypes() == [
assert [x.replace(" ", "") for x in m.print_dtypes()] == [
simple_dtype_fmt(),
packed_dtype_fmt(),
"[('a',{}),('b',{})]".format(simple_dtype_fmt(), packed_dtype_fmt()),
@ -238,7 +238,7 @@ def test_recarray(simple_dtype, packed_dtype):
]
arr = m.create_rec_partial(3)
assert str(arr.dtype) == partial_dtype_fmt()
assert str(arr.dtype).replace(" ", "") == partial_dtype_fmt()
partial_dtype = arr.dtype
assert "" not in arr.dtype.fields
assert partial_dtype.itemsize > simple_dtype.itemsize
@ -246,7 +246,7 @@ def test_recarray(simple_dtype, packed_dtype):
assert_equal(arr, elements, packed_dtype)
arr = m.create_rec_partial_nested(3)
assert str(arr.dtype) == partial_nested_fmt()
assert str(arr.dtype).replace(" ", "") == partial_nested_fmt()
assert "" not in arr.dtype.fields
assert "" not in arr.dtype.fields["a"][0].fields
assert arr.dtype.itemsize > partial_dtype.itemsize
@ -285,7 +285,7 @@ def test_array_array():
e = "<" if byteorder == "little" else ">"
arr = m.create_array_array(3)
assert str(arr.dtype) == (
assert str(arr.dtype).replace(" ", "") == (
"{{'names':['a','b','c','d'],"
+ "'formats':[('S4',(3,)),('"
+ e