mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Do not use the default namespace for attributes.
Fixes http://bugs.debian.org/229885 Will backport to 2.3.
This commit is contained in:
parent
d7911a3317
commit
9f1340b9f2
2 changed files with 26 additions and 16 deletions
|
@ -13,6 +13,8 @@ testdoc = """\
|
|||
<greeting>Hello, world!</greeting>
|
||||
"""
|
||||
|
||||
nsdoc = "<foo xmlns='URI' attr='val'/>"
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", ".* xmllib .* obsolete.*",
|
||||
DeprecationWarning, r'xmllib$')
|
||||
|
@ -29,6 +31,18 @@ class XMLParserTestCase(unittest.TestCase):
|
|||
parser.feed(c)
|
||||
parser.close()
|
||||
|
||||
def test_default_namespace(self):
|
||||
class H(xmllib.XMLParser):
|
||||
def unknown_starttag(self, name, attr):
|
||||
self.name, self.attr = name, attr
|
||||
h=H()
|
||||
h.feed(nsdoc)
|
||||
h.close()
|
||||
# The default namespace applies to elements...
|
||||
self.assertEquals(h.name, "URI foo")
|
||||
# but not to attributes
|
||||
self.assertEquals(h.attr, {'attr':'val'})
|
||||
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(XMLParserTestCase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue