Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
thiesmoeller committed Oct 30, 2024
1 parent e46d1c5 commit d738c17
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/pylon_tests/emulated/pylonimage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit d738c17

Please sign in to comment.