File: test-properties2.py

package info (click to toggle)
pyxb 1.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 63,792 kB
  • ctags: 48,994
  • sloc: python: 235,928; sh: 803; xml: 657; makefile: 57
file content (41 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download
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
# -*- coding: utf-8 -*-
import logging
if __name__ == '__main__':
    logging.basicConfig()
_log = logging.getLogger(__name__)
import pyxb
import pyxb.binding.generate
import pyxb.utils.domutils
from xml.dom import Node

import pyxb.binding.basis
import os.path
schema_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../schemas/test-collision.xsd'))
code = pyxb.binding.generate.GeneratePython(schema_location=schema_path)
#open('code.py', 'w').write(code)

rv = compile(code, 'test', 'exec')
eval(rv)

from pyxb.utils import domutils

import unittest

class TestCollision (unittest.TestCase):

    def testBasic (self):
        instance = color(color_.red, color_=color_.green)
        xmlt = u'<color color="green"><color>red</color></color>'
        xmld = xmlt.encode('utf-8')
        self.assertEqual(instance.toxml("utf-8", root_only=True), xmld)
        instance.color = color_.blue
        xmlt = u'<color color="green"><color>blue</color></color>'
        xmld = xmlt.encode('utf-8')
        self.assertEqual(instance.toxml("utf-8", root_only=True), xmld)
        instance.color_ = color_.red
        xmlt = u'<color color="red"><color>blue</color></color>'
        xmld = xmlt.encode('utf-8')
        self.assertEqual(instance.toxml("utf-8", root_only=True), xmld)

if __name__ == '__main__':
    unittest.main()