[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-06-27 03:42:25 +00:00
parent f33d985b40
commit f6e9d8a307
8 changed files with 959 additions and 738 deletions

View File

@ -189,7 +189,7 @@ processed_images/
# But keep README images and documentation images # But keep README images and documentation images
!README*.jpg !README*.jpg
!README*.jpeg !README*.jpeg
!README*.png !README*.png
!README*.gif !README*.gif
!docs/*.jpg !docs/*.jpg
@ -233,4 +233,4 @@ dist/
*.dmg *.dmg
# But keep our custom spec file # But keep our custom spec file
!pillow-cli.spec !pillow-cli.spec

View File

@ -42,4 +42,4 @@ if exist "dist\pillow-cli.exe" (
echo ERROR: Build failed. Check the output above for errors. echo ERROR: Build failed. Check the output above for errors.
) )
pause pause

View File

@ -61,4 +61,4 @@ exe = EXE(
codesign_identity=None, codesign_identity=None,
entitlements_file=None, entitlements_file=None,
icon=None, icon=None,
) )

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ testpaths = .
python_files = test_*.py python_files = test_*.py
python_classes = Test* python_classes = Test*
python_functions = test_* python_functions = test_*
addopts = addopts =
-v -v
--tb=short --tb=short
--strict-markers --strict-markers
@ -21,4 +21,4 @@ markers =
filterwarnings = filterwarnings =
ignore::DeprecationWarning ignore::DeprecationWarning
ignore::PendingDeprecationWarning ignore::PendingDeprecationWarning

View File

@ -8,4 +8,4 @@ pyinstaller>=5.13.0
# Testing dependencies # Testing dependencies
pytest>=7.0.0 pytest>=7.0.0
pytest-cov>=4.0.0 pytest-cov>=4.0.0
pytest-mock>=3.10.0 pytest-mock>=3.10.0

View File

@ -2,10 +2,14 @@
Test setup and fixtures for the Pillow CLI project Test setup and fixtures for the Pillow CLI project
""" """
import pytest from __future__ import annotations
import tempfile
import shutil
import os import os
import shutil
import tempfile
import pytest
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
@ -20,9 +24,12 @@ def test_data_dir():
@pytest.fixture @pytest.fixture
def create_test_image(): def create_test_image():
"""Helper to make test images on demand""" """Helper to make test images on demand"""
def _create_image(size=(100, 100), color='red', format='JPEG', mode='RGB', save_path=None):
def _create_image(
size=(100, 100), color="red", format="JPEG", mode="RGB", save_path=None
):
image = Image.new(mode, size, color=color) image = Image.new(mode, size, color=color)
# Add some visual elements to make it more realistic # Add some visual elements to make it more realistic
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)
if size[0] >= 50 and size[1] >= 50: if size[0] >= 50 and size[1] >= 50:
@ -30,23 +37,26 @@ def create_test_image():
rect_size = min(size[0] // 2, size[1] // 2) rect_size = min(size[0] // 2, size[1] // 2)
x1, y1 = size[0] // 4, size[1] // 4 x1, y1 = size[0] // 4, size[1] // 4
x2, y2 = x1 + rect_size, y1 + rect_size x2, y2 = x1 + rect_size, y1 + rect_size
if mode == 'RGB': if mode == "RGB":
draw.rectangle([x1, y1, x2, y2], fill='blue') draw.rectangle([x1, y1, x2, y2], fill="blue")
elif mode == 'RGBA': elif mode == "RGBA":
draw.rectangle([x1, y1, x2, y2], fill=(0, 0, 255, 200)) draw.rectangle([x1, y1, x2, y2], fill=(0, 0, 255, 200))
# Circle around the edge if there's room # Circle around the edge if there's room
if size[0] >= 20 and size[1] >= 20: if size[0] >= 20 and size[1] >= 20:
margin = 5 margin = 5
draw.ellipse([margin, margin, size[0] - margin, size[1] - margin], draw.ellipse(
outline='green', width=2) [margin, margin, size[0] - margin, size[1] - margin],
outline="green",
width=2,
)
if save_path: if save_path:
image.save(save_path, format) image.save(save_path, format)
return save_path return save_path
return image return image
return _create_image return _create_image
@ -54,16 +64,16 @@ def create_test_image():
def sample_images_batch(test_data_dir, create_test_image): def sample_images_batch(test_data_dir, create_test_image):
"""Makes a batch of sample images for testing""" """Makes a batch of sample images for testing"""
images = [] images = []
colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange'] colors = ["red", "green", "blue", "yellow", "purple", "orange"]
sizes = [(50, 50), (100, 100), (150, 100), (100, 150)] sizes = [(50, 50), (100, 100), (150, 100), (100, 150)]
for i, (color, size) in enumerate(zip(colors, sizes * 2)): # cycle through sizes for i, (color, size) in enumerate(zip(colors, sizes * 2)): # cycle through sizes
if i >= len(colors): if i >= len(colors):
break break
image_path = os.path.join(test_data_dir, f"batch_image_{i:02d}.jpg") image_path = os.path.join(test_data_dir, f"batch_image_{i:02d}.jpg")
create_test_image(size=size, color=color, save_path=image_path) create_test_image(size=size, color=color, save_path=image_path)
images.append(image_path) images.append(image_path)
return images return images
@ -71,37 +81,33 @@ def sample_images_batch(test_data_dir, create_test_image):
def sample_formats(test_data_dir, create_test_image): def sample_formats(test_data_dir, create_test_image):
"""Creates test images in different formats for conversion testing""" """Creates test images in different formats for conversion testing"""
formats_data = {} formats_data = {}
# JPEG # JPEG
jpeg_path = os.path.join(test_data_dir, "sample.jpg") jpeg_path = os.path.join(test_data_dir, "sample.jpg")
formats_data['jpeg'] = create_test_image(save_path=jpeg_path, format='JPEG') formats_data["jpeg"] = create_test_image(save_path=jpeg_path, format="JPEG")
# PNG with transparency # PNG with transparency
png_path = os.path.join(test_data_dir, "sample.png") png_path = os.path.join(test_data_dir, "sample.png")
formats_data['png'] = create_test_image(save_path=png_path, format='PNG', mode='RGBA') formats_data["png"] = create_test_image(
save_path=png_path, format="PNG", mode="RGBA"
)
# BMP # BMP
bmp_path = os.path.join(test_data_dir, "sample.bmp") bmp_path = os.path.join(test_data_dir, "sample.bmp")
formats_data['bmp'] = create_test_image(save_path=bmp_path, format='BMP') formats_data["bmp"] = create_test_image(save_path=bmp_path, format="BMP")
# GIF # GIF
gif_path = os.path.join(test_data_dir, "sample.gif") gif_path = os.path.join(test_data_dir, "sample.gif")
formats_data['gif'] = create_test_image(save_path=gif_path, format='GIF') formats_data["gif"] = create_test_image(save_path=gif_path, format="GIF")
return formats_data return formats_data
def pytest_configure(config): def pytest_configure(config):
"""Add our custom test markers""" """Add our custom test markers"""
config.addinivalue_line( config.addinivalue_line("markers", "unit: mark test as a unit test")
"markers", "unit: mark test as a unit test" config.addinivalue_line("markers", "integration: mark test as an integration test")
) config.addinivalue_line("markers", "slow: mark test as slow running")
config.addinivalue_line(
"markers", "integration: mark test as an integration test"
)
config.addinivalue_line(
"markers", "slow: mark test as slow running"
)
config.addinivalue_line( config.addinivalue_line(
"markers", "gui: mark test as GUI-related (may require display)" "markers", "gui: mark test as GUI-related (may require display)"
) )
@ -113,15 +119,15 @@ def pytest_collection_modifyitems(config, items):
# Unit tests # Unit tests
if "TestPillowCLI" in item.nodeid: if "TestPillowCLI" in item.nodeid:
item.add_marker(pytest.mark.unit) item.add_marker(pytest.mark.unit)
# Integration tests # Integration tests
elif "TestIntegration" in item.nodeid: elif "TestIntegration" in item.nodeid:
item.add_marker(pytest.mark.integration) item.add_marker(pytest.mark.integration)
# Slow tests (batch processing, large files, etc.) # Slow tests (batch processing, large files, etc.)
if "batch_process" in item.name or "large_dimensions" in item.name: if "batch_process" in item.name or "large_dimensions" in item.name:
item.add_marker(pytest.mark.slow) item.add_marker(pytest.mark.slow)
# GUI tests # GUI tests
if "gui" in item.name.lower(): if "gui" in item.name.lower():
item.add_marker(pytest.mark.gui) item.add_marker(pytest.mark.gui)

File diff suppressed because it is too large Load Diff