63f0ac3ee6ee1d5e5c91b8008437cd666890deab
[htsworkflow.git] / htsworkflow / util / test / test_ethelp.py
1 import os
2 import unittest
3
4 try:
5   from xml.etree import ElementTree
6 except ImportError, e:
7   from elementtree import ElementTree
8
9 from htsworkflow.util.ethelp import indent, flatten
10
11 class testETHelper(unittest.TestCase):
12     def setUp(self):
13         self.foo = '<foo><bar>asdf</bar><br/></foo>'
14         self.foo_tree = ElementTree.fromstring(self.foo)
15
16     def test_indent(self):
17         flat_foo = ElementTree.tostring(self.foo_tree)
18         self.failUnlessEqual(len(flat_foo.split('\n')), 1)
19
20         indent(self.foo_tree)
21         pretty_foo = ElementTree.tostring(self.foo_tree)
22         self.failUnlessEqual(len(pretty_foo.split('\n')), 5)
23
24     def test_flatten(self):
25         self.failUnless(flatten(self.foo_tree), 'asdf')
26
27 def suite():
28     return unittest.makeSuite(testETHelper, 'test')
29
30 if __name__ == "__main__":
31     unittest.main(defaultTest='suite')
32
33
34
35