mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
More morph tests
This commit is contained in:
parent
04f28b691e
commit
4c86ef0b52
|
@ -218,6 +218,61 @@ class MorphTests(PillowTestCase):
|
|||
self.assertRaises(Exception, lambda: mop.match(im))
|
||||
self.assertRaises(Exception, lambda: mop.get_on_pixels(im))
|
||||
|
||||
def test_add_patterns(self):
|
||||
# Arrange
|
||||
lb = ImageMorph.LutBuilder(op_name='corner')
|
||||
self.assertEqual(lb.patterns, ['1:(... ... ...)->0',
|
||||
'4:(00. 01. ...)->1'])
|
||||
new_patterns = ['M:(00. 01. ...)->1',
|
||||
'N:(00. 01. ...)->1']
|
||||
|
||||
# Act
|
||||
lb.add_patterns(new_patterns)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(
|
||||
lb.patterns,
|
||||
['1:(... ... ...)->0',
|
||||
'4:(00. 01. ...)->1',
|
||||
'M:(00. 01. ...)->1',
|
||||
'N:(00. 01. ...)->1'])
|
||||
|
||||
def test_unknown_pattern(self):
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
lambda: ImageMorph.LutBuilder(op_name='unknown'))
|
||||
|
||||
def test_pattern_syntax_error(self):
|
||||
# Arrange
|
||||
lb = ImageMorph.LutBuilder(op_name='corner')
|
||||
new_patterns = ['a pattern with a syntax error']
|
||||
lb.add_patterns(new_patterns)
|
||||
|
||||
# Act / Assert
|
||||
self.assertRaises(
|
||||
Exception,
|
||||
lambda: lb.build_lut())
|
||||
|
||||
def test_load_invalid_mrl(self):
|
||||
# Arrange
|
||||
invalid_mrl = 'Tests/images/hopper.png'
|
||||
mop = ImageMorph.MorphOp()
|
||||
|
||||
# Act / Assert
|
||||
self.assertRaises(Exception, lambda: mop.load_lut(invalid_mrl))
|
||||
|
||||
def test_set_lut(self):
|
||||
# Arrange
|
||||
lb = ImageMorph.LutBuilder(op_name='corner')
|
||||
lut = lb.build_lut()
|
||||
mop = ImageMorph.MorphOp()
|
||||
|
||||
# Act
|
||||
mop.set_lut(lut)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(mop.lut, lut)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user