diff --git a/tests/pylon_tests/emulated/pylonimage_test.py b/tests/pylon_tests/emulated/pylonimage_test.py index 19230d4..c73c530 100644 --- a/tests/pylon_tests/emulated/pylonimage_test.py +++ b/tests/pylon_tests/emulated/pylonimage_test.py @@ -70,6 +70,27 @@ def test_container_load_zero_copy(self): self.assertEqual(zc[0,0], 143) testee.Release() + def test_attacharray(self): + import numpy as np + import sys + + img = pylon.PylonImage() + arr = np.random.randint(0, 256, (480, 640), dtype=np.uint8) + + arr_refcount_0 = sys.getrefcount(arr) + img.AttachArray(arr, pylon.PixelType_Mono8) + # check proper refcounting attach + self.assertEqual( sys.getrefcount(arr) , arr_refcount_0 + 1) + + # check that img and array have same content + self.assertEqual(np.all(arr == img.Array), True) + + del img + # check proper refcounting free + self.assertEqual( sys.getrefcount(arr), arr_refcount_0) + + + if __name__ == "__main__": # import sys;sys.argv = ['', 'Test.testName'] unittest.main()