File: test-normalizedString.py

package info (click to toggle)
pyxb 1.2.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 42,668 kB
  • sloc: python: 239,437; sh: 905; xml: 690; makefile: 60
file content (28 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (3)
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
# -*- coding: utf-8 -*-
import logging
if __name__ == '__main__':
    logging.basicConfig()
_log = logging.getLogger(__name__)
from pyxb.exceptions_ import *
import unittest
import pyxb.binding.datatypes as xsd

class Test_normalizedString (unittest.TestCase):
    Cases = [ ("with\nnewline", 'with newline'),
              ("with\rreturn", 'with return'),
              ("with\ttab", 'with tab'),
              ("\n\nleading newline", '  leading newline'),
              ("trailing newline\n\n", 'trailing newline  '),
              ]

    def testValid (self):
        for (lexical, value) in self.Cases:
            self.assertEqual(value, xsd.normalizedString(value))
            self.assertEqual(value, xsd.normalizedString(lexical, _from_xml=True))

    def testInvalid (self):
        for (lexical, value) in self.Cases:
            self.assertRaises(SimpleTypeValueError, xsd.normalizedString, lexical)

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