mirror of
https://github.com/python/cpython
synced 2024-09-05 00:05:39 +00:00
gh-96175: add missing self._localName assignment in xml.dom.minidom.Attr
(#96176)
X-Ref: https://github.com/python/typeshed/pull/8590#discussion_r951473977 Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
575f8880bf
commit
58f6953d6d
|
@ -9,7 +9,7 @@
|
|||
import pyexpat
|
||||
import xml.dom.minidom
|
||||
|
||||
from xml.dom.minidom import parse, Node, Document, parseString
|
||||
from xml.dom.minidom import parse, Attr, Node, Document, parseString
|
||||
from xml.dom.minidom import getDOMImplementation
|
||||
from xml.parsers.expat import ExpatError
|
||||
|
||||
|
@ -77,6 +77,20 @@ def testParseFromTextFile(self):
|
|||
dom.unlink()
|
||||
self.confirm(isinstance(dom, Document))
|
||||
|
||||
def testAttrModeSetsParamsAsAttrs(self):
|
||||
attr = Attr("qName", "namespaceURI", "localName", "prefix")
|
||||
self.assertEqual(attr.name, "qName")
|
||||
self.assertEqual(attr.namespaceURI, "namespaceURI")
|
||||
self.assertEqual(attr.prefix, "prefix")
|
||||
self.assertEqual(attr.localName, "localName")
|
||||
|
||||
def testAttrModeSetsNonOptionalAttrs(self):
|
||||
attr = Attr("qName", "namespaceURI", None, "prefix")
|
||||
self.assertEqual(attr.name, "qName")
|
||||
self.assertEqual(attr.namespaceURI, "namespaceURI")
|
||||
self.assertEqual(attr.prefix, "prefix")
|
||||
self.assertEqual(attr.localName, attr.name)
|
||||
|
||||
def testGetElementsByTagName(self):
|
||||
dom = parse(tstfile)
|
||||
self.confirm(dom.getElementsByTagName("LI") == \
|
||||
|
|
|
@ -358,6 +358,8 @@ def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None,
|
|||
self._name = qName
|
||||
self.namespaceURI = namespaceURI
|
||||
self._prefix = prefix
|
||||
if localName is not None:
|
||||
self._localName = localName
|
||||
self.childNodes = NodeList()
|
||||
|
||||
# Add the single child node that represents the value of the attr
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix unused ``localName`` parameter in the ``Attr`` class in :mod:`xml.dom.minidom`.
|
Loading…
Reference in a new issue