diff --git a/PythonClient/airsim/types.py b/PythonClient/airsim/types.py index 7aef005549..d4c63005fe 100644 --- a/PythonClient/airsim/types.py +++ b/PythonClient/airsim/types.py @@ -323,8 +323,8 @@ def __init__(self, camera_name, image_type, pixels_as_float = False, compress = class ImageResponse(MsgpackMixin): - image_data_uint8 = np.uint8(0) - image_data_float = 0.0 + image_data_uint8 = b"" + image_data_float = [] camera_position = Vector3r() camera_orientation = Quaternionr() time_stamp = np.uint64(0) diff --git a/PythonClient/tests/__init__.py b/PythonClient/tests/__init__.py new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/PythonClient/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/PythonClient/tests/test_image_response_types.py b/PythonClient/tests/test_image_response_types.py new file mode 100644 index 0000000000..5f349de1da --- /dev/null +++ b/PythonClient/tests/test_image_response_types.py @@ -0,0 +1,21 @@ +import unittest + +from airsim.types import ImageResponse + + +class TestImageResponseDefaults(unittest.TestCase): + def test_default_buffers_are_empty_iterables(self): + r = ImageResponse() + self.assertIsInstance(r.image_data_uint8, (bytes, bytearray)) + self.assertEqual(len(r.image_data_uint8), 0) + self.assertIsInstance(r.image_data_float, list) + self.assertEqual(len(r.image_data_float), 0) + # Sample code paths + self.assertEqual(len(r.image_data_uint8), 0) + import numpy as np + arr = np.frombuffer(r.image_data_uint8, dtype=np.uint8) + self.assertEqual(arr.size, 0) + + +if __name__ == "__main__": + unittest.main()