1 '''Test module to thest the xmllib module.
6 <?xml version="1.0" encoding="UTF-8" standalone='yes' ?>
7 <!-- comments aren't allowed before the <?xml?> tag,
8 but they are allowed before the <!DOCTYPE> tag -->
9 <?processing instructions are allowed in the same places as comments ?>
11 <!ELEMENT greeting (#PCDATA)>
13 <greeting>Hello, world!</greeting>
16 nsdoc
= "<foo xmlns='URI' attr='val'/>"
19 warnings
.filterwarnings("ignore", ".* xmllib .* obsolete.*",
20 DeprecationWarning, r
'xmllib$')
22 from test
import test_support
26 class XMLParserTestCase(unittest
.TestCase
):
28 def test_simple(self
):
29 parser
= xmllib
.XMLParser()
34 def test_default_namespace(self
):
35 class H(xmllib
.XMLParser
):
36 def unknown_starttag(self
, name
, attr
):
37 self
.name
, self
.attr
= name
, attr
41 # The default namespace applies to elements...
42 self
.assertEquals(h
.name
, "URI foo")
43 # but not to attributes
44 self
.assertEquals(h
.attr
, {'attr':'val'})
48 test_support
.run_unittest(XMLParserTestCase
)
50 if __name__
== "__main__":