Merge branch 'main' into duru

This commit is contained in:
dutcu 2024-06-20 12:05:40 +02:00
commit 22ef3e07a4
3 changed files with 31 additions and 1 deletions

View File

@ -17,3 +17,4 @@ def test_sanity(data_type: str) -> None:
im2 = Image.frombytes(im1.mode, im1.size, data)
assert_image_equal(im1, im2)

View File

@ -0,0 +1,30 @@
import pytest
from PIL import Image
def calculate_branch_coverage():
b = Image.Branches
print("Branches covered:", sum(b.values()))
def test_merge_wrong_number_of_bands():
R = Image.new('L', (100, 100), color=255)
G = Image.new('L', (100, 100), color=128)
with pytest.raises(ValueError, match="wrong number of bands"):
Image.merge('RGB', [R, G])
def test_merge_mode_mismatch():
R = Image.new('L', (100, 100), color=255)
G = Image.new('L', (100, 100), color=128)
B = Image.new('1', (100, 100)) # Incorrect mode
with pytest.raises(ValueError, match="mode mismatch"):
Image.merge('RGB', [R, G, B])
def test_merge_size_mismatch():
R = Image.new('L', (100, 100), color=255)
G = Image.new('L', (200, 100), color=128) # Different size
B = Image.new('L', (100, 100), color=0)
with pytest.raises(ValueError, match="size mismatch"):
Image.merge('RGB', [R, G, B])

View File

@ -25,7 +25,6 @@ def calculate_coverage(test_name):
print(f"{name} - Total branches: {num_branches}")
print(f"{name} - BRANCH COVERAGE: {coverage}%\n")
return all_branches["branches1"]