def test_open_img(self): img = imgs.create_rgb() # given an Pillow Image, open_img should return the same instance self.assertEqual(id(img), id(analyse.open_img(img))) # given an path, open_img should return a Pillow Image instance with imgs.TempFile(img) as img_path: opened_img = analyse.open_img(img_path) self.assertTrue(isinstance(opened_img, Image.Image)) self.assertEqual(list(img.getdata()), list(opened_img.getdata()))
def test_open_img_nonexistent(self): with self.assertRaisesRegexp(AssertionError, 'not a file'): analyse.open_img('nonexistent')