Skip to content

Commit a5f036a

Browse files
committed
Moved messages into assert method calls
1 parent d324560 commit a5f036a

1 file changed

Lines changed: 28 additions & 32 deletions

File tree

Tests/test_image_resample.py

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,9 @@ def test_passthrough(self):
502502
((40, 50), (10, 0, 50, 50)),
503503
((40, 50), (10, 20, 50, 70)),
504504
]:
505-
try:
506-
res = im.resize(size, Image.LANCZOS, box)
507-
self.assertEqual(res.size, size)
508-
self.assert_image_equal(res, im.crop(box))
509-
except AssertionError:
510-
print(">>>", size, box)
511-
raise
505+
res = im.resize(size, Image.LANCZOS, box)
506+
self.assertEqual(res.size, size)
507+
self.assert_image_equal(res, im.crop(box), ">>> {} {}".format(size, box))
512508

513509
def test_no_passthrough(self):
514510
# When resize is required
@@ -520,15 +516,13 @@ def test_no_passthrough(self):
520516
((40, 50), (10.4, 0.4, 50.4, 50.4)),
521517
((40, 50), (10.4, 20.4, 50.4, 70.4)),
522518
]:
523-
try:
524-
res = im.resize(size, Image.LANCZOS, box)
525-
self.assertEqual(res.size, size)
526-
with self.assertRaisesRegex(AssertionError, r"difference \d"):
527-
# check that the difference at least that much
528-
self.assert_image_similar(res, im.crop(box), 20)
529-
except AssertionError:
530-
print(">>>", size, box)
531-
raise
519+
res = im.resize(size, Image.LANCZOS, box)
520+
self.assertEqual(res.size, size)
521+
with self.assertRaisesRegex(AssertionError, r"difference \d"):
522+
# check that the difference at least that much
523+
self.assert_image_similar(
524+
res, im.crop(box), 20, ">>> {} {}".format(size, box)
525+
)
532526

533527
def test_skip_horizontal(self):
534528
# Can skip resize for one dimension
@@ -541,14 +535,15 @@ def test_skip_horizontal(self):
541535
((40, 50), (10, 0, 50, 90)),
542536
((40, 50), (10, 20, 50, 90)),
543537
]:
544-
try:
545-
res = im.resize(size, flt, box)
546-
self.assertEqual(res.size, size)
547-
# Borders should be slightly different
548-
self.assert_image_similar(res, im.crop(box).resize(size, flt), 0.4)
549-
except AssertionError:
550-
print(">>>", size, box, flt)
551-
raise
538+
res = im.resize(size, flt, box)
539+
self.assertEqual(res.size, size)
540+
# Borders should be slightly different
541+
self.assert_image_similar(
542+
res,
543+
im.crop(box).resize(size, flt),
544+
0.4,
545+
">>> {} {} {}".format(size, box, flt),
546+
)
552547

553548
def test_skip_vertical(self):
554549
# Can skip resize for one dimension
@@ -561,11 +556,12 @@ def test_skip_vertical(self):
561556
((40, 50), (0, 10, 90, 60)),
562557
((40, 50), (20, 10, 90, 60)),
563558
]:
564-
try:
565-
res = im.resize(size, flt, box)
566-
self.assertEqual(res.size, size)
567-
# Borders should be slightly different
568-
self.assert_image_similar(res, im.crop(box).resize(size, flt), 0.4)
569-
except AssertionError:
570-
print(">>>", size, box, flt)
571-
raise
559+
res = im.resize(size, flt, box)
560+
self.assertEqual(res.size, size)
561+
# Borders should be slightly different
562+
self.assert_image_similar(
563+
res,
564+
im.crop(box).resize(size, flt),
565+
0.4,
566+
">>> {} {} {}".format(size, box, flt),
567+
)

0 commit comments

Comments
 (0)