source: trunk/packages/xen-common/xen-common/tools/python/xen/xend/tests/test_sxp.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 1015 bytes
Line 
1import unittest
2
3import xen.xend.sxp
4
5
6class test_sxp(unittest.TestCase):
7
8    def testAllFromString(self):
9        def t(inp, expected):
10            self.assertEqual(xen.xend.sxp.all_from_string(inp), expected)
11
12        t('String',           ['String'])
13        t('(String Thing)',   [['String', 'Thing']])
14        t('(String) (Thing)', [['String'], ['Thing']])
15
16
17    def testParseFixed(self):
18        fin = file('../xen/xend/tests/xend-config.sxp', 'rb')
19        try:
20            config = xen.xend.sxp.parse(fin)
21            self.assertEqual(
22                xen.xend.sxp.child_value(
23                config,
24                'xend-relocation-hosts-allow'),
25                '^localhost$ ^localhost\\.localdomain$')
26        finally:
27            fin.close()
28
29
30    def testParseConfigExample(self):
31        fin = file('../../examples/xend-config.sxp', 'rb')
32        try:
33            config = xen.xend.sxp.parse(fin)
34        finally:
35            fin.close()
36
37
38def test_suite():
39    return unittest.makeSuite(test_sxp)
Note: See TracBrowser for help on using the repository browser.