Fixed deprecation warning with Python 2.6
[rox-lib.git] / ROX-Lib2 / tests / python / testicon_theme.py
bloba80f9dc1e1d466118b7eaf730c581be9ce98ab60
1 #!/usr/bin/env python2.6
2 import unittest
3 import os, sys, shutil
4 from os.path import dirname, abspath, join
5 rox_lib = dirname(dirname(dirname(abspath(sys.argv[0]))))
6 sys.path.insert(0, join(rox_lib, 'python'))
8 from rox import icon_theme
9 from StringIO import StringIO
11 test_index = StringIO("""[Section]
13 a=1
15 b=2
16 c = 3
18 [Another]
19 #Comment
20 a = Hello
21 # Another comment
22 b = 2""")
24 class TestIconTheme(unittest.TestCase):
25 def testParser(self):
26 i = icon_theme._ini_parser(test_index)
27 self.assertEquals(("Section", "a", "1"), i.next())
28 self.assertEquals(("Section", "b", "2"), i.next())
29 self.assertEquals(("Section", "c", "3"), i.next())
30 self.assertEquals(("Another", "a", "Hello"), i.next())
31 self.assertEquals(("Another", "b", "2"), i.next())
32 for x in i: assert 0
34 def testLeadingComment(self):
35 i = icon_theme._ini_parser(StringIO("#Hello"))
36 for x in i: assert 0
38 def testMissingSection(self):
39 i = icon_theme._ini_parser(StringIO("Hello"))
40 try:
41 i.next()
42 assert 0
43 except Exception:
44 pass
46 suite = unittest.makeSuite(TestIconTheme)
47 if __name__ == '__main__':
48 sys.argv.append('-v')
49 unittest.main()