Skip to content

Commit 55c1a22

Browse files
Make local copy of image_data for ref count test
1 parent 548f95c commit 55c1a22

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎tests/test_image.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,15 @@ def test_ImageFactory(self):
189189

190190
def test_ref_counts(self):
191191
# opening from data keeps reference to buffer
192-
count = sys.getrefcount(self.image_data)
193-
image = exiv2.ImageFactory.open(self.image_data)
194-
self.assertEqual(sys.getrefcount(self.image_data), count + 1)
192+
image_data = bytearray(self.image_data)
193+
count = sys.getrefcount(image_data)
194+
image = exiv2.ImageFactory.open(image_data)
195+
self.assertEqual(sys.getrefcount(image_data), count + 1)
195196
# writeMetadata releases buffer
196197
image.writeMetadata()
197-
self.assertEqual(sys.getrefcount(self.image_data), count)
198+
self.assertEqual(sys.getrefcount(image_data), count)
198199
# getting metadata and buffers keeps reference to image
199-
image = exiv2.ImageFactory.open(self.image_data)
200+
image = exiv2.ImageFactory.open(image_data)
200201
image.readMetadata()
201202
count = sys.getrefcount(image)
202203
data = [image.exifData()]

0 commit comments

Comments
 (0)