diff --git a/test/python/unittest/API/APITest.py b/test/python/unittest/API/APITest.py index a510098c8d..bd24e4a6b4 100644 --- a/test/python/unittest/API/APITest.py +++ b/test/python/unittest/API/APITest.py @@ -264,7 +264,24 @@ def attributeRoundTrip(self, file_ending): self.assertEqual(series.get_attribute("char"), "c") self.assertEqual(series.get_attribute("pystring"), "howdy!") self.assertEqual(series.get_attribute("pystring2"), "howdy, too!") - self.assertEqual(bytes(series.get_attribute("pystring3")), + if file_ending == 'h5': + # A byte string b"hello" is always (really?) a vector of unsigned + # chars. + # HDF5 does not distinguish a platform char type, only explicitly + # signed or unsigned chars. Depending on the signed-ness of char + # on the current platform, the unsigned char from the byte string + # might then be interpreted as a char, not as an unsigned char. + # This means that the roundtrip might not work on platforms with + # unsigned char. + try: + as_bytes = bytes(series.get_attribute("pystring3")) + self.assertEqual(as_bytes, b"howdy, again!") + except TypeError: + self.assertEqual( + series.get_attribute("pystring3"), + [c for c in "howdy, again!"]) + else: + self.assertEqual(bytes(series.get_attribute("pystring3")), b"howdy, again!") self.assertEqual(series.get_attribute("pyint"), 13) self.assertAlmostEqual(series.get_attribute("pyfloat"), 3.1416)