[go: up one dir, main page]

Menu

[r881]: / Segtool / test_section.py  Maximize  Restore  History

Download this file

48 lines (35 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
modules = {'Section' : [0, '', 'none://Section.py' ]
}
from Section import Section
from Section import ImageSegmentation
from Section import GlobalColors
from lxml import etree
import unittest
class TestSectionIO(unittest.TestCase):
def setUp(self):
self.points = [(0,0), (1,2), (4,12)]
self.points_upscaled = [(0,0), (2,4), (8,24)]
color = "red"
self.section = Section(color=color,points=self.points)
def testEqualSelf(self):
self.assertEqual(self.section, self.section)
def testModel(self):
root = etree.Element("frame")
self.section.Save(root)
self.assertEqual(len(root), 1,
msg=etree.tostring(root, pretty_print=True))
for s in root:
load_section = Section(node=s)
self.assertEqual(load_section, self.section, msg=etree.tostring(s, pretty_print=True) )
def testGetPoints(self):
points = self.section.GetPoints( 2.0 )
self.assertEqual(points, self.points_upscaled)
def testSetPoints(self):
self.section.SetPoints( self.points_upscaled, 2.0 )
self.assertEqual(self.section.points, self.points)
def suite():
suite = unittest.makeSuite(TestSectionIO, 'test')
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')