ImageFields now include PIL error messages if invalid error (#353)

This commit is contained in:
Ross Lawley
2013-06-05 11:45:08 +00:00
parent a246154961
commit e5648a4af9
3 changed files with 14 additions and 2 deletions

View File

@@ -269,6 +269,17 @@ class FileTest(unittest.TestCase):
TestImage.drop_collection()
with tempfile.TemporaryFile() as f:
f.write(b("Hello World!"))
f.flush()
t = TestImage()
try:
t.image.put(f)
self.fail("Should have raised an invalidation error")
except ValidationError, e:
self.assertEquals("%s" % e, "Invalid image: cannot identify image file")
t = TestImage()
t.image.put(open(TEST_IMAGE_PATH, 'rb'))
t.save()