mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	flake8
This commit is contained in:
		
							parent
							
								
									37841dbaeb
								
							
						
					
					
						commit
						2c4a1209f4
					
				| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
from PIL import Image
 | 
					from PIL import Image
 | 
				
			||||||
from helper import unittest, PillowTestCase
 | 
					from helper import unittest, PillowTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestJ2kEncodeOverflow(PillowTestCase):
 | 
					class TestJ2kEncodeOverflow(PillowTestCase):
 | 
				
			||||||
    def test_j2k_overflow(self):
 | 
					    def test_j2k_overflow(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +13,7 @@ class TestJ2kEncodeOverflow(PillowTestCase):
 | 
				
			||||||
        except IOError as err:
 | 
					        except IOError as err:
 | 
				
			||||||
            self.assertTrue(True, "IOError is expected")
 | 
					            self.assertTrue(True, "IOError is expected")
 | 
				
			||||||
        except Exception as err:
 | 
					        except Exception as err:
 | 
				
			||||||
            self.assertTrue(False, "Expected IOError, got %s" %type(err))
 | 
					            self.assertTrue(False, "Expected IOError, got %s" % type(err))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    unittest.main()
 | 
					    unittest.main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,5 @@ class TestFileBmp(PillowTestCase):
 | 
				
			||||||
        self.assert_image_equal(im, target)
 | 
					        self.assert_image_equal(im, target)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    unittest.main()
 | 
					    unittest.main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,7 +170,8 @@ class TestFileLibTiff(LibTiffTestCase):
 | 
				
			||||||
                                'RowsPerStrip',
 | 
					                                'RowsPerStrip',
 | 
				
			||||||
                                'StripOffsets']
 | 
					                                'StripOffsets']
 | 
				
			||||||
            for field in requested_fields:
 | 
					            for field in requested_fields:
 | 
				
			||||||
                self.assertTrue(field in reloaded, "%s not in metadata" % field)
 | 
					                self.assertTrue(field in reloaded,
 | 
				
			||||||
 | 
					                                "%s not in metadata" % field)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_additional_metadata(self):
 | 
					    def test_additional_metadata(self):
 | 
				
			||||||
        # these should not crash. Seriously dummy data, most of it doesn't make
 | 
					        # these should not crash. Seriously dummy data, most of it doesn't make
 | 
				
			||||||
| 
						 | 
					@ -183,7 +184,8 @@ class TestFileLibTiff(LibTiffTestCase):
 | 
				
			||||||
                                                        in TiffTags.LIBTIFF_CORE]
 | 
					                                                        in TiffTags.LIBTIFF_CORE]
 | 
				
			||||||
                          if info.type is not None)
 | 
					                          if info.type is not None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Exclude ones that have special meaning that we're already testing them
 | 
					        # Exclude ones that have special meaning
 | 
				
			||||||
 | 
					        # that we're already testing them
 | 
				
			||||||
        im = Image.open('Tests/images/hopper_g4.tif')
 | 
					        im = Image.open('Tests/images/hopper_g4.tif')
 | 
				
			||||||
        for tag in im.tag_v2.keys():
 | 
					        for tag in im.tag_v2.keys():
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
| 
						 | 
					@ -422,8 +424,8 @@ class TestFileLibTiff(LibTiffTestCase):
 | 
				
			||||||
    def test_gray_semibyte_per_pixel(self):
 | 
					    def test_gray_semibyte_per_pixel(self):
 | 
				
			||||||
        test_files = (
 | 
					        test_files = (
 | 
				
			||||||
            (
 | 
					            (
 | 
				
			||||||
                24.8,#epsilon
 | 
					                24.8,  # epsilon
 | 
				
			||||||
                (#group
 | 
					                (  # group
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper2.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper2.tif",
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper2I.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper2I.tif",
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper2R.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper2R.tif",
 | 
				
			||||||
| 
						 | 
					@ -431,8 +433,8 @@ class TestFileLibTiff(LibTiffTestCase):
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            (
 | 
					            (
 | 
				
			||||||
                7.3,#epsilon
 | 
					                7.3,  # epsilon
 | 
				
			||||||
                (#group
 | 
					                (  # group
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper4.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper4.tif",
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper4I.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper4I.tif",
 | 
				
			||||||
                    "Tests/images/tiff_gray_2_4_bpp/hopper4R.tif",
 | 
					                    "Tests/images/tiff_gray_2_4_bpp/hopper4R.tif",
 | 
				
			||||||
| 
						 | 
					@ -504,6 +506,5 @@ class TestFileLibTiff(LibTiffTestCase):
 | 
				
			||||||
        im.save(outfile)
 | 
					        im.save(outfile)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    unittest.main()
 | 
					    unittest.main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -313,7 +313,7 @@ class TestFilePng(PillowTestCase):
 | 
				
			||||||
        #                  -14: malformed chunk
 | 
					        #                  -14: malformed chunk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for offset in (-10, -13, -14):
 | 
					        for offset in (-10, -13, -14):
 | 
				
			||||||
            with open(TEST_PNG_FILE,'rb') as f:
 | 
					            with open(TEST_PNG_FILE, 'rb') as f:
 | 
				
			||||||
                test_file = f.read()[:offset]
 | 
					                test_file = f.read()[:offset]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            im = Image.open(BytesIO(test_file))
 | 
					            im = Image.open(BytesIO(test_file))
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,6 @@ class TestFilePng(PillowTestCase):
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            ImageFile.LOAD_TRUNCATED_IMAGES = False
 | 
					            ImageFile.LOAD_TRUNCATED_IMAGES = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test_roundtrip_dpi(self):
 | 
					    def test_roundtrip_dpi(self):
 | 
				
			||||||
        # Check dpi roundtripping
 | 
					        # Check dpi roundtripping
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -105,6 +105,7 @@ class TestCffiPutPixel(TestImagePutPixel):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            import cffi
 | 
					            import cffi
 | 
				
			||||||
 | 
					            assert cffi  # silence warning
 | 
				
			||||||
        except ImportError:
 | 
					        except ImportError:
 | 
				
			||||||
            self.skipTest("No cffi")
 | 
					            self.skipTest("No cffi")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,6 +116,7 @@ class TestCffiGetPixel(TestImageGetPixel):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            import cffi
 | 
					            import cffi
 | 
				
			||||||
 | 
					            assert cffi  # silence warning
 | 
				
			||||||
        except ImportError:
 | 
					        except ImportError:
 | 
				
			||||||
            self.skipTest("No cffi")
 | 
					            self.skipTest("No cffi")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,6 +127,7 @@ class TestCffi(AccessTest):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            import cffi
 | 
					            import cffi
 | 
				
			||||||
 | 
					            assert cffi  # silence warning
 | 
				
			||||||
        except ImportError:
 | 
					        except ImportError:
 | 
				
			||||||
            self.skipTest("No cffi")
 | 
					            self.skipTest("No cffi")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,7 @@ from PIL import ImagePath, Image
 | 
				
			||||||
import array
 | 
					import array
 | 
				
			||||||
import struct
 | 
					import struct
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestImagePath(PillowTestCase):
 | 
					class TestImagePath(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_path(self):
 | 
					    def test_path(self):
 | 
				
			||||||
| 
						 | 
					@ -61,7 +62,6 @@ class TestImagePath(PillowTestCase):
 | 
				
			||||||
            p = ImagePath.Path(arr.tostring())
 | 
					            p = ImagePath.Path(arr.tostring())
 | 
				
			||||||
        self.assertEqual(list(p), [(0.0, 1.0)])
 | 
					        self.assertEqual(list(p), [(0.0, 1.0)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test_overflow_segfault(self):
 | 
					    def test_overflow_segfault(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # post patch, this fails with a memory error
 | 
					            # post patch, this fails with a memory error
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ class TestImageSequence(PillowTestCase):
 | 
				
			||||||
        im = Image.open('Tests/images/multipage.tiff')
 | 
					        im = Image.open('Tests/images/multipage.tiff')
 | 
				
			||||||
        firstFrame = None
 | 
					        firstFrame = None
 | 
				
			||||||
        for frame in ImageSequence.Iterator(im):
 | 
					        for frame in ImageSequence.Iterator(im):
 | 
				
			||||||
            if firstFrame == None:
 | 
					            if firstFrame is None:
 | 
				
			||||||
                firstFrame = frame.copy()
 | 
					                firstFrame = frame.copy()
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        for frame in ImageSequence.Iterator(im):
 | 
					        for frame in ImageSequence.Iterator(im):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ except (OSError, ImportError) as v:
 | 
				
			||||||
    # Skipped via setUp()
 | 
					    # Skipped via setUp()
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestImageTk(PillowTestCase):
 | 
					class TestImageTk(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
| 
						 | 
					@ -24,7 +25,7 @@ class TestImageTk(PillowTestCase):
 | 
				
			||||||
        im2 = Image.open(TEST_PNG)
 | 
					        im2 = Image.open(TEST_PNG)
 | 
				
			||||||
        with open(TEST_PNG, 'rb') as fp:
 | 
					        with open(TEST_PNG, 'rb') as fp:
 | 
				
			||||||
            data = fp.read()
 | 
					            data = fp.read()
 | 
				
			||||||
        kw = {"file":TEST_JPG, "data":data}
 | 
					        kw = {"file": TEST_JPG, "data": data}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Test "file"
 | 
					        # Test "file"
 | 
				
			||||||
        im = ImageTk._get_image_from_kw(kw)
 | 
					        im = ImageTk._get_image_from_kw(kw)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,10 @@ if sys.platform.startswith('win32'):
 | 
				
			||||||
    DeleteObject.argtypes = [ctypes.wintypes.HGDIOBJ]
 | 
					    DeleteObject.argtypes = [ctypes.wintypes.HGDIOBJ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CreateDIBSection = ctypes.windll.gdi32.CreateDIBSection
 | 
					    CreateDIBSection = ctypes.windll.gdi32.CreateDIBSection
 | 
				
			||||||
    CreateDIBSection.argtypes = [ctypes.wintypes.HDC, ctypes.c_void_p, ctypes.c_uint, ctypes.POINTER(ctypes.c_void_p), ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD]
 | 
					    CreateDIBSection.argtypes = [ctypes.wintypes.HDC, ctypes.c_void_p,
 | 
				
			||||||
 | 
					                                 ctypes.c_uint,
 | 
				
			||||||
 | 
					                                 ctypes.POINTER(ctypes.c_void_p),
 | 
				
			||||||
 | 
					                                 ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD]
 | 
				
			||||||
    CreateDIBSection.restype = ctypes.wintypes.HBITMAP
 | 
					    CreateDIBSection.restype = ctypes.wintypes.HBITMAP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def serialize_dib(bi, pixels):
 | 
					    def serialize_dib(bi, pixels):
 | 
				
			||||||
| 
						 | 
					@ -99,7 +102,8 @@ if sys.platform.startswith('win32'):
 | 
				
			||||||
            hdc = CreateCompatibleDC(None)
 | 
					            hdc = CreateCompatibleDC(None)
 | 
				
			||||||
            # print('hdc:',hex(hdc))
 | 
					            # print('hdc:',hex(hdc))
 | 
				
			||||||
            pixels = ctypes.c_void_p()
 | 
					            pixels = ctypes.c_void_p()
 | 
				
			||||||
            dib = CreateDIBSection(hdc, ctypes.byref(hdr), DIB_RGB_COLORS, ctypes.byref(pixels), None, 0)
 | 
					            dib = CreateDIBSection(hdc, ctypes.byref(hdr), DIB_RGB_COLORS,
 | 
				
			||||||
 | 
					                                   ctypes.byref(pixels), None, 0)
 | 
				
			||||||
            SelectObject(hdc, dib)
 | 
					            SelectObject(hdc, dib)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            imdib.expose(hdc)
 | 
					            imdib.expose(hdc)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,8 @@ from PIL import Image
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    import site
 | 
					    import site
 | 
				
			||||||
    import numpy
 | 
					    import numpy
 | 
				
			||||||
 | 
					    assert site  # silence warning
 | 
				
			||||||
 | 
					    assert numpy  # silence warning
 | 
				
			||||||
except ImportError:
 | 
					except ImportError:
 | 
				
			||||||
    # Skip via setUp()
 | 
					    # Skip via setUp()
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
| 
						 | 
					@ -18,6 +20,8 @@ class TestNumpy(PillowTestCase):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            import site
 | 
					            import site
 | 
				
			||||||
            import numpy
 | 
					            import numpy
 | 
				
			||||||
 | 
					            assert site  # silence warning
 | 
				
			||||||
 | 
					            assert numpy  # silence warning
 | 
				
			||||||
        except ImportError:
 | 
					        except ImportError:
 | 
				
			||||||
            self.skipTest("ImportError")
 | 
					            self.skipTest("ImportError")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user