Skip to content

Commit ad98c2b

Browse files
Fix some little-endian assumptions in the tests (#49913)
TST: Fix some little-endian assumptions See previous PR#46681.
1 parent 2508ba9 commit ad98c2b

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

pandas/tests/arrays/floating/test_arithmetic.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ def test_error_invalid_values(data, all_arithmetic_operators):
162162
"not all arguments converted during string formatting",
163163
"can't multiply sequence by non-int of type 'float'",
164164
"ufunc 'subtract' cannot use operands with types dtype",
165-
r"ufunc 'add' cannot use operands with types dtype\('<M8\[ns\]'\)",
165+
(
166+
"ufunc 'add' cannot use operands with types "
167+
rf"dtype\('{tm.ENDIAN}M8\[ns\]'\)"
168+
),
166169
r"ufunc 'add' cannot use operands with types dtype\('float\d{2}'\)",
167170
"cannot subtract DatetimeArray from ndarray",
168171
]

pandas/tests/frame/methods/test_to_records.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ def test_to_records_index_name(self):
9696
+ [np.asarray(df.iloc[:, i]) for i in range(3)],
9797
dtype={
9898
"names": ["A", "level_1", "0", "1", "2"],
99-
"formats": ["O", "O", "<f8", "<f8", "<f8"],
99+
"formats": [
100+
"O",
101+
"O",
102+
f"{tm.ENDIAN}f8",
103+
f"{tm.ENDIAN}f8",
104+
f"{tm.ENDIAN}f8",
105+
],
100106
},
101107
)
102108
tm.assert_numpy_array_equal(result, expected)
@@ -123,7 +129,11 @@ def test_to_records_index_dtype(self):
123129
("2022-01-01", "2022-01-01", "2022-01-01"),
124130
("2022-01-02", "2022-01-02", "2022-01-02"),
125131
],
126-
dtype=[("1", "<M8[ns]"), ("2", "<M8[ns]"), ("3", "<M8[ns]")],
132+
dtype=[
133+
("1", f"{tm.ENDIAN}M8[ns]"),
134+
("2", f"{tm.ENDIAN}M8[ns]"),
135+
("3", f"{tm.ENDIAN}M8[ns]"),
136+
],
127137
)
128138

129139
result = df.to_records(index=False)

pandas/tests/scalar/timedelta/test_arithmetic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def test_td_mul_td64_ndarray_invalid(self):
435435

436436
msg = (
437437
"ufunc '?multiply'? cannot use operands with types "
438-
r"dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
438+
rf"dtype\('{tm.ENDIAN}m8\[ns\]'\) and dtype\('{tm.ENDIAN}m8\[ns\]'\)"
439439
)
440440
with pytest.raises(TypeError, match=msg):
441441
td * other

0 commit comments

Comments
 (0)