diff --git a/tests/test_buffers.py b/tests/test_buffers.py index 4a60ea4261..62c3efd388 100644 --- a/tests/test_buffers.py +++ b/tests/test_buffers.py @@ -10,12 +10,13 @@ np = pytest.importorskip("numpy") -if m.std_is_same_double_long_double: # Windows. - np_float128 = None - np_complex256 = None -else: - np_float128 = np.float128 - np_complex256 = np.complex256 + +def np_dtype_long_double_or_none(name): + # Intentionally not using getattr(np, name, None), to be strict. + if m.std_is_same_double_long_double: # Windows. + return None + return getattr(np, name) + CPP_NAME_FORMAT_NP_DTYPE_TABLE = [ item @@ -32,10 +33,10 @@ ("std::uint64_t", "Q", np.uint64), ("float", "f", np.float32), ("double", "d", np.float64), - ("long double", "g", np_float128), + ("long double", "g", np_dtype_long_double_or_none("float128")), ("std::complex", "Zf", np.complex64), ("std::complex", "Zd", np.complex128), - ("std::complex", "Zg", np_complex256), + ("std::complex", "Zg", np_dtype_long_double_or_none("complex256")), ] if item[-1] is not None ]