Exemplo n.º 1
0
 def test_Image_equality(self):
     p = self.TEST_IMAGE['path']
     i1, i2 = Image.load(filepath=p), Image.load(filepath=p)
     self.assertTrue(i1 == i2)
     self.assertEquals(i1, i2)
     i1[0][0] = (0, 0, 0)
     self.assertTrue(i1 != i2)
Exemplo n.º 2
0
    def test_save(self):
        name, ext = os.path.splitext(self.TEST_IMAGE['path'])
        test_out = '%s%s%s' % (name, '_test', ext)
        try:
            changed_pixel = (1, 2, 3)
            self.i[0][0] = changed_pixel
            self.i.save(test_out)
            self.assertTrue(exists(test_out))

            # Load it back
            i = Image.load(filepath=test_out)
            self.assertTrue(i.width, self.TEST_IMAGE['size'][0])
            self.assertTrue(i.height, self.TEST_IMAGE['size'][1])
            self.assertEquals(i[0][1], self.i[0][1])
            self.assertEquals(i[0][0], changed_pixel)
        finally:
            try:
                os.unlink(test_out)
            except EnvironmentError:
                pass
Exemplo n.º 3
0
 def setUp(self):
     assert exists(self.TEST_IMAGE['path']), \
             'Test picture missing: %s' % self.TEST_IMAGE['path']
     self.i = Image.load(filepath=self.TEST_IMAGE['path'])