File: test_sxp.py

package info (click to toggle)
xen-3.0 3.0.3-0-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 31,772 kB
  • ctags: 70,362
  • sloc: ansic: 417,153; python: 28,855; asm: 23,892; sh: 5,157; makefile: 4,830; objc: 613; perl: 372; xml: 351
file content (39 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download | duplicates (7)
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
import unittest

import xen.xend.sxp


class test_sxp(unittest.TestCase):

    def testAllFromString(self):
        def t(inp, expected):
            self.assertEqual(xen.xend.sxp.all_from_string(inp), expected)

        t('String',           ['String'])
        t('(String Thing)',   [['String', 'Thing']])
        t('(String) (Thing)', [['String'], ['Thing']])


    def testParseFixed(self):
        fin = file('../xen/xend/tests/xend-config.sxp', 'rb')
        try:
            config = xen.xend.sxp.parse(fin)
            self.assertEqual(
                xen.xend.sxp.child_value(
                config,
                'xend-relocation-hosts-allow'),
                '^localhost$ ^localhost\\.localdomain$')
        finally:
            fin.close()


    def testParseConfigExample(self):
        fin = file('../../examples/xend-config.sxp', 'rb')
        try:
            config = xen.xend.sxp.parse(fin)
        finally:
            fin.close()


def test_suite():
    return unittest.makeSuite(test_sxp)