Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Tests/test_color_lut.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations

from array import array
from types import ModuleType

import pytest

from PIL import Image, ImageFilter

from .helper import assert_image_equal

TYPE_CHECKING = False
if TYPE_CHECKING:
from types import ModuleType

numpy: ModuleType | None
try:
import numpy
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_apng.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

from io import BytesIO
from pathlib import Path

import pytest

from PIL import Image, ImageSequence, PngImagePlugin

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path


# APNG browser support tests and fixtures via:
# https://philip.html5.org/tests/apng/tests.html
Expand Down
7 changes: 5 additions & 2 deletions Tests/test_file_avif.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import os
import re
import warnings
from collections.abc import Generator, Sequence
from contextlib import contextmanager
from io import BytesIO
from pathlib import Path
from typing import Any

import pytest
Expand All @@ -32,6 +30,11 @@
skip_unless_feature_version,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Generator, Sequence
from pathlib import Path

try:
from PIL import _avif

Expand Down
6 changes: 4 additions & 2 deletions Tests/test_file_blp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from pathlib import Path

import pytest

from PIL import BlpImagePlugin, Image
Expand All @@ -12,6 +10,10 @@
hopper,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path


def test_load_blp1() -> None:
with Image.open("Tests/images/blp/blp1_jpeg.blp") as im:
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_bmp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import io
from pathlib import Path

import pytest

Expand All @@ -16,6 +15,10 @@
hopper,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path


@pytest.mark.parametrize("mode", ("1", "L", "P", "RGB"))
def test_sanity(mode: str, tmp_path: Path) -> None:
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_bufrstub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from pathlib import Path
from typing import IO

import pytest
Expand All @@ -9,6 +8,10 @@

from .helper import hopper

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_FILE = "Tests/images/gfs.t06z.rassda.tm00.bufr_d"


Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

from io import BytesIO
from pathlib import Path

import pytest

Expand All @@ -17,6 +16,10 @@
hopper,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds"
TEST_FILE_DXT3 = "Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds"
TEST_FILE_DXT5 = "Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.dds"
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io
import subprocess
from pathlib import Path

import pytest

Expand All @@ -19,6 +18,10 @@
timeout_unless_slower_valgrind,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()

# Our two EPS test files (they are identical except for their bounding boxes)
Expand Down
7 changes: 5 additions & 2 deletions Tests/test_file_gif.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

import warnings
from collections.abc import Generator
from io import BytesIO
from pathlib import Path
from typing import Any

import pytest
Expand All @@ -19,6 +17,11 @@
netpbm_available,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path

# sample gif stream
TEST_GIF = "Tests/images/hopper.gif"

Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_gribstub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from pathlib import Path
from typing import IO

import pytest
Expand All @@ -9,6 +8,10 @@

from .helper import hopper

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_FILE = "Tests/images/WAlaska.wind.7days.grb"


Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

from io import BytesIO
from pathlib import Path
from typing import IO

import pytest

from PIL import Hdf5StubImagePlugin, Image, ImageFile

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_FILE = "Tests/images/hdf5.h5"


Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_icns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import io
import os
import warnings
from pathlib import Path

import pytest

from PIL import IcnsImagePlugin, Image, _binary

from .helper import assert_image_equal, assert_image_similar_tofile, skip_unless_feature

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

# sample icon file
TEST_FILE = "Tests/images/pillow.icns"

Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_ico.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import io
import os
from pathlib import Path

import pytest

from PIL import IcoImagePlugin, Image, ImageDraw, ImageFile

from .helper import assert_image_equal, assert_image_equal_tofile, hopper

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_ICO_FILE = "Tests/images/hopper.ico"


Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_im.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import filecmp
import warnings
from pathlib import Path

import pytest

from PIL import Image, ImImagePlugin

from .helper import assert_image_equal_tofile, hopper, is_pypy

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

# sample im
TEST_IM = "Tests/images/hopper.im"

Expand Down
9 changes: 6 additions & 3 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import struct
import warnings
from io import BytesIO
from pathlib import Path
from types import ModuleType
from typing import Any, cast

import pytest
Expand Down Expand Up @@ -35,6 +33,11 @@
timeout_unless_slower_valgrind,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path
from types import ModuleType

ElementTree: ModuleType | None
try:
from defusedxml import ElementTree
Expand All @@ -53,7 +56,7 @@ def roundtrip_with_bytes(
im.save(out, "JPEG", **options)
test_bytes = out.tell()
out.seek(0)
reloaded = cast(JpegImagePlugin.JpegImageFile, Image.open(out))
reloaded = cast("JpegImagePlugin.JpegImageFile", Image.open(out))
return reloaded, test_bytes

def roundtrip(
Expand Down
7 changes: 5 additions & 2 deletions Tests/test_file_jpeg2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import os
import re
import struct
from collections.abc import Generator
from io import BytesIO
from pathlib import Path
from typing import Any

import pytest
Expand All @@ -27,6 +25,11 @@
skip_unless_feature_version,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path

EXTRA_DIR = "Tests/images/jpeg2000"

pytestmark = skip_unless_feature("jpg_2000")
Expand Down
8 changes: 6 additions & 2 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import os
import re
import sys
from pathlib import Path
from typing import Any, NamedTuple
from typing import NamedTuple

import pytest

Expand All @@ -32,6 +31,11 @@
skip_unless_feature,
)

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path
from typing import Any


@skip_unless_feature("libtiff")
class LibTiffTestCase:
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_libtiff_small.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

from io import BytesIO
from pathlib import Path

from PIL import Image

from .test_file_libtiff import LibTiffTestCase

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path


class TestFileLibTiffSmall(LibTiffTestCase):
"""The small lena image was failing on open in the libtiff
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_mcidas.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations

import struct
from pathlib import Path

import pytest

from PIL import Image, McIdasImagePlugin

from .helper import assert_image_equal_tofile

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path


def test_invalid_file() -> None:
invalid_file = "Tests/images/flower.jpg"
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_file_msp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations

import os
from pathlib import Path

import pytest

from PIL import Image, MspImagePlugin

from .helper import assert_image_equal, assert_image_equal_tofile, hopper

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

TEST_FILE = "Tests/images/hopper.msp"
EXTRA_DIR = "Tests/images/picins"
YA_EXTRA_DIR = "Tests/images/msp"
Expand Down
Loading
Loading