mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Changed file opening in tests to use with
This commit is contained in:
		
							parent
							
								
									751a6d1c2d
								
							
						
					
					
						commit
						c10ad19a2b
					
				| 
						 | 
				
			
			@ -505,17 +505,17 @@ class TestFilePng(PillowTestCase):
 | 
			
		|||
        im.convert("P").save(test_file, dpi=(100, 100))
 | 
			
		||||
 | 
			
		||||
        chunks = []
 | 
			
		||||
        fp = open(test_file, "rb")
 | 
			
		||||
        fp.read(8)
 | 
			
		||||
        png = PngImagePlugin.PngStream(fp)
 | 
			
		||||
        while True:
 | 
			
		||||
            cid, pos, length = png.read()
 | 
			
		||||
            chunks.append(cid)
 | 
			
		||||
            try:
 | 
			
		||||
                s = png.call(cid, pos, length)
 | 
			
		||||
            except EOFError:
 | 
			
		||||
                break
 | 
			
		||||
            png.crc(cid, s)
 | 
			
		||||
        with open(test_file, "rb") as fp:
 | 
			
		||||
            fp.read(8)
 | 
			
		||||
            png = PngImagePlugin.PngStream(fp)
 | 
			
		||||
            while True:
 | 
			
		||||
                cid, pos, length = png.read()
 | 
			
		||||
                chunks.append(cid)
 | 
			
		||||
                try:
 | 
			
		||||
                    s = png.call(cid, pos, length)
 | 
			
		||||
                except EOFError:
 | 
			
		||||
                    break
 | 
			
		||||
                png.crc(cid, s)
 | 
			
		||||
 | 
			
		||||
        # https://www.w3.org/TR/PNG/#5ChunkOrdering
 | 
			
		||||
        # IHDR - shall be first
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -495,12 +495,12 @@ class TestFileTiff(PillowTestCase):
 | 
			
		|||
        with Image.open("Tests/images/uint16_1_4660.tif") as im:
 | 
			
		||||
            im.save(tmpfile)
 | 
			
		||||
 | 
			
		||||
        f = open(tmpfile, 'rb')
 | 
			
		||||
        im = Image.open(f)
 | 
			
		||||
        fp = im.fp
 | 
			
		||||
        self.assertFalse(fp.closed)
 | 
			
		||||
        im.load()
 | 
			
		||||
        self.assertFalse(fp.closed)
 | 
			
		||||
        with open(tmpfile, 'rb') as f:
 | 
			
		||||
            im = Image.open(f)
 | 
			
		||||
            fp = im.fp
 | 
			
		||||
            self.assertFalse(fp.closed)
 | 
			
		||||
            im.load()
 | 
			
		||||
            self.assertFalse(fp.closed)
 | 
			
		||||
 | 
			
		||||
@unittest.skipUnless(sys.platform.startswith('win32'), "Windows only")
 | 
			
		||||
class TestFileTiffW32(PillowTestCase):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,8 +9,8 @@ class TestFontBdf(PillowTestCase):
 | 
			
		|||
 | 
			
		||||
    def test_sanity(self):
 | 
			
		||||
 | 
			
		||||
        test_file = open(filename, "rb")
 | 
			
		||||
        font = BdfFontFile.BdfFontFile(test_file)
 | 
			
		||||
        with open(filename, "rb") as test_file:
 | 
			
		||||
            font = BdfFontFile.BdfFontFile(test_file)
 | 
			
		||||
 | 
			
		||||
        self.assertIsInstance(font, FontFile.FontFile)
 | 
			
		||||
        self.assertEqual(len([_f for _f in font.glyph if _f]), 190)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,8 +17,8 @@ class TestFontPcf(PillowTestCase):
 | 
			
		|||
            self.skipTest("zlib support not available")
 | 
			
		||||
 | 
			
		||||
    def save_font(self):
 | 
			
		||||
        test_file = open(fontname, "rb")
 | 
			
		||||
        font = PcfFontFile.PcfFontFile(test_file)
 | 
			
		||||
        with open(fontname, "rb") as test_file:
 | 
			
		||||
            font = PcfFontFile.PcfFontFile(test_file)
 | 
			
		||||
        self.assertIsInstance(font, FontFile.FontFile)
 | 
			
		||||
        self.assertEqual(len([_f for _f in font.glyph if _f]), 192)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user