8000 add some tests we'd dropped · libvips/pyvips@bf0cba7 · GitHub
[go: up one dir, main page]

Skip to content

Commit bf0cba7

Browse files
committed
add some tests we'd dropped
from libvips master
1 parent aba9504 commit bf0cba7

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

pyvips/tests/test_arithmetic.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,19 @@ def test_measure(self):
546546
self.assertAlmostEqual(p1, 0)
547547
self.assertAlmostEqual(p2, 10)
548548

549+
def test_find_trim(self):
550+
im = pyvips.Image.black(50, 60) + 100
551+
test = im.embed(10, 20, 200, 300, extend = "white")
552+
553+
for x in unsigned_formats + float_formats:
554+
a = test.cast(x)
555+
left, top, width, height = a.find_trim()
556+
557+
self.< 8000 span class=pl-c1>assertEqual(left, 10)
558+
self.assertEqual(top, 20)
559+
self.assertEqual(width, 50)
560+
self.assertEqual(height, 60)
561+
549562
def test_profile(self):
550563
test = pyvips.Image.black(100, 100).draw_rect(100, 40, 50, 1, 1)
551564

pyvips/tests/test_iofuncs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,27 @@ def split(path):
3434
for case in cases:
3535
self.assertEqualObjects(split(case[0]), case[1])
3636

37+
def test_new_from_image(self):
38+
im = pyvips.Image.mask_ideal(100, 100, 0.5,
39+
reject = True, optical = True)
40+
41+
im2 = im.new_from_image(12)
42+
43+
self.assertEqual(im2.width, im.width)
44+
self.assertEqual(im2.height, im.height)
45+
self.assertEqual(im2.interpretation, im.interpretation)
46+
self.assertEqual(im2.format, im.format)
47+
self.assertEqual(im2.xres, im.xres)
48+
self.assertEqual(im2.yres, im.yres)
49+
self.assertEqual(im2.xoffset, im.xoffset)
50+
self.assertEqual(im2.yoffset, im.yoffset)
51+
self.assertEqual(im2.bands, 1)
52+
self.assertEqual(im2.avg(), 12)
53+
54+
im2 = im.new_from_image([1,2,3])
55+
56+
self.assertEqual(im2.bands, 3)
57+
self.assertEqual(im2.avg(), 2)
58+
3759
if __name__ == '__main__':
3860
unittest.main()

0 commit comments

Comments
 (0)
0