Ejemplo n.º 1
0
 def testInvalid(self):
     invalid = ['-NonName', '-also:-not', 'and:-not', 'too:many:colons']
     for f in invalid:
         try:
             xsd.QName(f)
             print 'Unexpected pass with %s' % (f, )
         except:
             pass
         self.assertRaises(BadTypeValueError, xsd.QName, f)
Ejemplo n.º 2
0
    def testValid(self):
        dns = pyxb.namespace.CreateAbsentNamespace()
        nsc = pyxb.namespace.NamespaceContext(target_namespace=dns)
        nsc.declareNamespace(xsi, 'xsi')

        self.assertEqual('schema', xsd.QName('schema', _xmlns_context=nsc))
        self.assertEqual('schema', xsd.QName('schema'))
        self.assertEqual(xsi.createExpandedName('something'),
                         xsd.QName('xsi:something', _xmlns_context=nsc))
        with self.assertRaises(pyxb.QNameResolutionError) as cm:
            xsd.QName('xs:something', _xmlns_context=nsc)
        self.assertEqual('xs:something', cm.exception.qname)
        self.assertEqual(nsc, cm.exception.namespaceContext)
        with self.assertRaises(pyxb.QNameResolutionError) as cm:
            xsd.QName('xsi:something')
        self.assertEqual('xsi:something', cm.exception.qname)
        self.assertEqual(None, cm.exception.namespaceContext)
        self.assertEqual('with.dots', xsd.QName('with.dots',
                                                _xmlns_context=nsc))
Ejemplo n.º 3
0
 def testValid(self):
     valid = ['schema', 'xs:something', 'with.dots']
     for f in valid:
         self.assertEqual(f, xsd.QName(f))
     self.assertEqual('whitespace', xsd.QName(' whitespace '))