def test_good_error_message_from_memory_full_error(self):
""" Tests a good error message from a library call that fails.
1. Correctly converts -52000 to NiFpgaMemoryFullError
2. An integer arg gets printed as hex (easier to debug than decimal)
3. A string arg gets printed with quotes surrounding it (so it's obviously a string)
"""
self._mock_awesome_function.return_value = -52000
try:
self._library.AwesomeFunction(ctypes.c_uint32(33), ctypes.c_char_p(b"2"))
self.fail("AwesomeFunction should have raised MemoryFull")
except nifpga.MemoryFullError as e:
if python_version == 2:
self.assertEqual(
"Error: MemoryFull (-52000) when calling 'Entrypoint_AwesomeFunction' with arguments:"
"\n\tsome_integer: 0x21L"
"\n\tsome_string: '2'", str(e))
else:
self.assertEqual(
"Error: MemoryFull (-52000) when calling 'Entrypoint_AwesomeFunction' with arguments:"
"\n\tsome_integer: 0x21"
"\n\tsome_string: b'2'", str(e))
评论列表
文章目录