Move location of fclose and add dump test.

This commit is contained in:
Kathryn Davies 2018-03-31 21:28:37 -07:00
parent 147f835146
commit 8f6be2ee7d
2 changed files with 10 additions and 4 deletions

View File

@ -112,7 +112,6 @@ class TestImage(PillowTestCase):
self.assertRaises(ValueError, im.save, temp_file)
def test_internals(self):
im = Image.new("L", (100, 100))
im.readonly = 1
im._copy()
@ -122,8 +121,15 @@ class TestImage(PillowTestCase):
im.paste(0, (0, 0, 100, 100))
self.assertFalse(im.readonly)
test_file = self.tempfile("temp.ppm")
im._dump(test_file)
def test_dump(self):
im = Image.new("L", (10, 10))
im._dump(self.tempfile("temp_L.ppm"))
im = Image.new("RGB", (10, 10))
im._dump(self.tempfile("temp_RGB.ppm"))
im = Image.new("HSV", (10, 10))
self.assertRaises(ValueError, im._dump, self.tempfile("temp_HSV.ppm"))
def test_comparison_with_other_type(self):
# Arrange

View File

@ -70,8 +70,8 @@ ImagingSavePPM(Imaging im, const char* outfile)
/* Write "PPM" */
fprintf(fp, "P6\n%d %d\n255\n", im->xsize, im->ysize);
} else {
(void) ImagingError_ModeError();
fclose(fp);
(void) ImagingError_ModeError();
return 0;
}