Skip to content

Commit 617f323

Browse files
committed
style: remove trailing whitespace in test_image_processor.py
1 parent 7c64ad7 commit 617f323

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

scripts/tests/test_image_processor.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,114 +3,115 @@
33
"""
44
import os
55
import unittest
6-
from unittest.mock import MagicMock, patch
6+
from unittest.mock import patch
77

88
from PIL import Image, ImageDraw
99

1010
import sys
11+
1112
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1213

1314
from image_processor import ImageProcessor
1415

1516

1617
class TestImageProcessor(unittest.TestCase):
1718
"""Tests for the ImageProcessor class"""
18-
19+
1920
def setUp(self):
2021
"""Set up test fixtures"""
2122
self.processor = ImageProcessor()
22-
23+
2324
# Create test images of different dimensions
2425
self.square_image = Image.new('RGBA', (100, 100), (255, 0, 0, 255))
2526
self.wide_image = Image.new('RGBA', (200, 100), (0, 255, 0, 255))
2627
self.tall_image = Image.new('RGBA', (100, 200), (0, 0, 255, 255))
27-
28+
2829
def test_crop_to_square_already_square(self):
2930
"""Test cropping an already square image"""
3031
result = self.processor.crop_to_square(self.square_image)
3132
self.assertEqual(result.size, (100, 100))
32-
33+
3334
def test_crop_to_square_wide_image(self):
3435
"""Test cropping a wide image to square"""
3536
result = self.processor.crop_to_square(self.wide_image)
3637
self.assertEqual(result.size, (100, 100))
37-
38+
3839
def test_crop_to_square_tall_image(self):
3940
"""Test cropping a tall image to square"""
4041
result = self.processor.crop_to_square(self.tall_image)
4142
self.assertEqual(result.size, (100, 100))
42-
43+
4344
def test_resize_image(self):
4445
"""Test resizing an image"""
4546
result = self.processor.resize_image(self.square_image, (50, 50))
4647
self.assertEqual(result.size, (50, 50))
47-
48+
4849
def test_apply_gradient_fade(self):
4950
"""Test applying gradient fade"""
5051
# Create a test image
5152
image = Image.new('RGBA', (100, 100), (255, 255, 255, 255))
52-
53+
5354
# Apply fade to bottom 20 pixels
5455
result = self.processor.apply_gradient_fade(image, 20)
55-
56+
5657
# Check size hasn't changed
5758
self.assertEqual(result.size, (100, 100))
58-
59+
5960
# Check that alpha channel has been modified
6061
# Top part should still be fully opaque
6162
self.assertEqual(result.getpixel((50, 10))[3], 255)
62-
63+
6364
# Bottom part should have reduced opacity
6465
self.assertLess(result.getpixel((50, 90))[3], 255)
65-
66+
6667
def test_create_background(self):
6768
"""Test creating a gradient background"""
6869
# Create a simple gradient
69-
result = self.processor.create_background((100, 100), "#FF0000", "#0000FF")
70-
70+
result = self.processor.create_background((100, 100), "#FF0000",
71+
"#0000FF")
72+
7173
# Check size
7274
self.assertEqual(result.size, (100, 100))
73-
75+
7476
# Check gradient - top should be reddish, bottom should be bluish
75-
r, g, b, a = result.getpixel((50, 10))
76-
self.assertGreater(r, b) # More red than blue at top
77-
78-
r, g, b, a = result.getpixel((50, 90))
79-
self.assertGreater(b, r) # More blue than red at bottom
80-
77+
r, _, b, _ = result.getpixel((50, 10))
78+
self.assertGreater(r, b)
79+
80+
r, _, b, _ = result.getpixel((50, 90))
81+
self.assertGreater(b, r)
82+
8183
@patch('image_processor.logger')
8284
def test_create_background_with_error(self, mock_logger):
8385
"""Test creating a background with invalid color values"""
8486
# Create a background with invalid color
85-
result = self.processor.create_background((100, 100), "invalid", "#0000FF")
86-
87+
result = self.processor.create_background((100, 100), "invalid",
88+
"#0000FF")
89+
8790
# Should fall back to solid color
8891
self.assertEqual(result.size, (100, 100))
89-
92+
9093
# Logger should have recorded the error
9194
mock_logger.error.assert_called_once()
92-
95+
9396
def test_position_logo(self):
9497
"""Test positioning a logo on an image"""
95-
# Create base image and logo
98+
9699
base_image = Image.new('RGBA', (200, 200), (255, 255, 255, 255))
97100
logo = Image.new('RGBA', (50, 25), (0, 0, 0, 255))
98-
99-
# Position logo with 10px margin
101+
100102
result = self.processor.position_logo(base_image, logo, 10, 0.25)
101-
102-
# Check size hasn't changed
103+
103104
self.assertEqual(result.size, (200, 200))
104-
105+
105106
# Logo should be in top-right corner
106107
# Base image is white, logo is black, so checking for non-white pixels
107108
# at the expected logo position
108-
109+
109110
# Logo width should be 25% of base image width = 50px
110111
# Logo should be at position (200 - 50 - 10, 10) = (140, 10)
111112
# Check pixel near the logo center
112-
r, g, b, a = result.getpixel((150, 15))
113-
self.assertLess(r + g + b, 100) # Should be dark (black logo)
113+
r, g, b, _ = result.getpixel((150, 15))
114+
self.assertLess(r + g + b, 100)
114115

115116

116117
if __name__ == '__main__':

0 commit comments

Comments
 (0)