Skip to content

Commit

Permalink
Merge pull request #1854 from hugovk/tga-rle
Browse files Browse the repository at this point in the history
Test TGA RLE file
  • Loading branch information
wiredfool committed Apr 29, 2016
2 parents 12bfb97 + 31b05ce commit 300ca19
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Binary file added Tests/images/rgb32rle.tga
Binary file not shown.
29 changes: 29 additions & 0 deletions Tests/test_file_tga.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ def test_id_field(self):
# Assert
self.assertEqual(im.size, (100, 100))

def test_id_field_rle(self):
# tga file with id field
test_file = "Tests/images/rgb32rle.tga"

# Act
im = Image.open(test_file)

# Assert
self.assertEqual(im.size, (199, 199))

def test_save(self):
test_file = "Tests/images/tga_id_field.tga"
im = Image.open(test_file)
Expand All @@ -34,6 +44,25 @@ def test_save(self):
# Unsupported mode save
self.assertRaises(IOError, lambda: im.convert("LA").save(test_file))

def test_save_rle(self):
test_file = "Tests/images/rgb32rle.tga"
im = Image.open(test_file)

test_file = self.tempfile("temp.tga")

# Save
im.save(test_file)
test_im = Image.open(test_file)
self.assertEqual(test_im.size, (199, 199))

# RGBA save
im.convert("RGBA").save(test_file)
test_im = Image.open(test_file)
self.assertEqual(test_im.size, (199, 199))

# Unsupported mode save
self.assertRaises(IOError, lambda: im.convert("LA").save(test_file))


if __name__ == '__main__':
unittest.main()

0 comments on commit 300ca19

Please sign in to comment.