mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 23:47:27 +03:00 
			
		
		
		
	Added type hints
This commit is contained in:
		
							parent
							
								
									15307955f7
								
							
						
					
					
						commit
						0842985ebc
					
				|  | @ -7,7 +7,7 @@ import pytest | ||||||
| from PIL import Image | from PIL import Image | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_aero_busy(): | def test_aero_busy() -> None: | ||||||
|     with Image.open("Tests/images/ani/aero_busy.ani") as im: |     with Image.open("Tests/images/ani/aero_busy.ani") as im: | ||||||
|         assert im.size == (64, 64) |         assert im.size == (64, 64) | ||||||
|         assert im.info["frames"] == 18 |         assert im.info["frames"] == 18 | ||||||
|  | @ -26,7 +26,7 @@ def test_aero_busy(): | ||||||
|             im.seek(18) |             im.seek(18) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_posy_busy(): | def test_posy_busy() -> None: | ||||||
|     with Image.open("Tests/images/ani/posy_busy.ani") as im: |     with Image.open("Tests/images/ani/posy_busy.ani") as im: | ||||||
|         assert im.size == (96, 96) |         assert im.size == (96, 96) | ||||||
|         assert im.info["frames"] == 77 |         assert im.info["frames"] == 77 | ||||||
|  | @ -42,7 +42,7 @@ def test_posy_busy(): | ||||||
|             im.seek(77) |             im.seek(77) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_stopwtch(): | def test_stopwtch() -> None: | ||||||
|     with Image.open("Tests/images/ani/stopwtch.ani") as im: |     with Image.open("Tests/images/ani/stopwtch.ani") as im: | ||||||
|         assert im.size == (32, 32) |         assert im.size == (32, 32) | ||||||
|         assert im.info["frames"] == 8 |         assert im.info["frames"] == 8 | ||||||
|  | @ -67,7 +67,7 @@ def test_stopwtch(): | ||||||
|             im.seek(8) |             im.seek(8) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_save(): | def test_save() -> None: | ||||||
|     directory_path = "Tests/images/ani/" |     directory_path = "Tests/images/ani/" | ||||||
|     filenames = [ |     filenames = [ | ||||||
|         "aero_busy_0.png", |         "aero_busy_0.png", | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ def test_deerstalker() -> None: | ||||||
|         assert im.getpixel((16, 16)) == (84, 87, 86, 255) |         assert im.getpixel((16, 16)) == (84, 87, 86, 255) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_posy_link(): | def test_posy_link() -> None: | ||||||
|     with Image.open("Tests/images/cur/posy_link.cur") as im: |     with Image.open("Tests/images/cur/posy_link.cur") as im: | ||||||
|         assert im.size == (128, 128) |         assert im.size == (128, 128) | ||||||
|         assert im.info["sizes"] == {(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)} |         assert im.info["sizes"] == {(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)} | ||||||
|  | @ -34,7 +34,7 @@ def test_posy_link(): | ||||||
|         assert im.getpixel((10, 10)) == (191, 191, 191, 255) |         assert im.getpixel((10, 10)) == (191, 191, 191, 255) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_stopwtch(): | def test_stopwtch() -> None: | ||||||
|     with Image.open("Tests/images/cur/stopwtch.cur") as im: |     with Image.open("Tests/images/cur/stopwtch.cur") as im: | ||||||
|         assert im.size == (32, 32) |         assert im.size == (32, 32) | ||||||
|         assert im.info["hotspots"] == [(16, 19)] |         assert im.info["hotspots"] == [(16, 19)] | ||||||
|  | @ -43,7 +43,7 @@ def test_stopwtch(): | ||||||
|         assert im.getpixel((8, 16)) == (255, 0, 0, 255) |         assert im.getpixel((8, 16)) == (255, 0, 0, 255) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_win98_arrow(): | def test_win98_arrow() -> None: | ||||||
|     with Image.open("Tests/images/cur/win98_arrow.cur") as im: |     with Image.open("Tests/images/cur/win98_arrow.cur") as im: | ||||||
|         assert im.size == (32, 32) |         assert im.size == (32, 32) | ||||||
|         assert im.info["hotspots"] == [(10, 10)] |         assert im.info["hotspots"] == [(10, 10)] | ||||||
|  | @ -68,7 +68,7 @@ def test_invalid_file() -> None: | ||||||
|             cur._open() |             cur._open() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_save_win98_arrow(): | def test_save_win98_arrow() -> None: | ||||||
|     with Image.open("Tests/images/cur/win98_arrow.png") as im: |     with Image.open("Tests/images/cur/win98_arrow.png") as im: | ||||||
|         # save the data |         # save the data | ||||||
|         with BytesIO() as output: |         with BytesIO() as output: | ||||||
|  | @ -80,20 +80,20 @@ def test_save_win98_arrow(): | ||||||
|                 bitmap_format="bmp", |                 bitmap_format="bmp", | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             with Image.open(output) as im2: |             with Image.open(output) as reloaded: | ||||||
|                 assert im.tobytes() == im2.tobytes() |                 assert im.tobytes() == reloaded.tobytes() | ||||||
| 
 | 
 | ||||||
|         with BytesIO() as output: |         with BytesIO() as output: | ||||||
|             im.save(output, format="CUR") |             im.save(output, format="CUR") | ||||||
| 
 | 
 | ||||||
|             # check default save params |             # check default save params | ||||||
|             with Image.open(output) as im2: |             with Image.open(output) as reloaded: | ||||||
|                 assert im2.size == (32, 32) |                 assert reloaded.size == (32, 32) | ||||||
|                 assert im2.info["sizes"] == {(32, 32), (24, 24), (16, 16)} |                 assert reloaded.info["sizes"] == {(32, 32), (24, 24), (16, 16)} | ||||||
|                 assert im2.info["hotspots"] == [(0, 0), (0, 0), (0, 0)] |                 assert reloaded.info["hotspots"] == [(0, 0), (0, 0), (0, 0)] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_save_posy_link(): | def test_save_posy_link() -> None: | ||||||
|     sizes = [(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)] |     sizes = [(128, 128), (96, 96), (64, 64), (48, 48), (32, 32)] | ||||||
|     hotspots = [(25, 7), (18, 5), (12, 3), (9, 2), (5, 1)] |     hotspots = [(25, 7), (18, 5), (12, 3), (9, 2), (5, 1)] | ||||||
| 
 | 
 | ||||||
|  | @ -110,18 +110,18 @@ def test_save_posy_link(): | ||||||
| 
 | 
 | ||||||
|             # make sure saved output is readable |             # make sure saved output is readable | ||||||
|             # and sizes/hotspots are correct |             # and sizes/hotspots are correct | ||||||
|             with Image.open(output, formats=["CUR"]) as im2: |             with Image.open(output, formats=["CUR"]) as reloaded: | ||||||
|                 assert (128, 128) == im2.size |                 assert (128, 128) == reloaded.size | ||||||
|                 assert set(sizes) == im2.info["sizes"] |                 assert set(sizes) == reloaded.info["sizes"] | ||||||
| 
 | 
 | ||||||
|         with BytesIO() as output: |         with BytesIO() as output: | ||||||
|             im.save(output, sizes=sizes[3:], hotspots=hotspots[3:], format="CUR") |             im.save(output, sizes=sizes[3:], hotspots=hotspots[3:], format="CUR") | ||||||
| 
 | 
 | ||||||
|             # make sure saved output is readable |             # make sure saved output is readable | ||||||
|             # and sizes/hotspots are correct |             # and sizes/hotspots are correct | ||||||
|             with Image.open(output, formats=["CUR"]) as im2: |             with Image.open(output, formats=["CUR"]) as reloaded: | ||||||
|                 assert (48, 48) == im2.size |                 assert (48, 48) == reloaded.size | ||||||
|                 assert set(sizes[3:]) == im2.info["sizes"] |                 assert set(sizes[3:]) == reloaded.info["sizes"] | ||||||
| 
 | 
 | ||||||
|             # make sure error is thrown when size and hotspot len's |             # make sure error is thrown when size and hotspot len's | ||||||
|             # don't match |             # don't match | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user