Skip to content

Commit 6c5b9b0

Browse files
Apply patch
Co-authored-by: Julian Gindi <[email protected]>
1 parent 79f7c67 commit 6c5b9b0

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

Lib/test/test_minidom.py

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,37 @@ def testChangeAttr(self):
396396
dom.unlink()
397397

398398
def testGetAttrList(self):
399-
pass
399+
dom = parseString("<abc/>")
400+
el = dom.documentElement
401+
el.setAttribute("spam", "jam")
402+
self.confirm(len(el.attributes.items()) == 1)
403+
el.setAttribute("foo", "bar")
404+
self.confirm(len(el.attributes.items()) == 2)
405+
self.confirm(('spam', 'jam') in el.attributes.items())
406+
self.confirm(('foo', 'bar') in el.attributes.items())
407+
dom.unlink()
400408

401409
def testGetAttrValues(self):
402-
pass
410+
dom = parseString("<abc/>")
411+
el = dom.documentElement
412+
el.setAttribute("spam", "jam")
413+
values = [x.value for x in el.attributes.values()]
414+
self.confirm("jam" in values)
415+
el.setAttribute("foo", "bar")
416+
values = [x.value for x in el.attributes.values()]
417+
self.confirm("bar" in values)
418+
dom.unlink()
403419

404420
def testGetAttrLength(self):
405-
pass
421+
dom = parseString("<abc/>")
422+
el = dom.documentElement
423+
el.setAttribute("spam", "jam")
424+
self.confirm(len(el.attributes.items()) == 1)
425+
el.setAttribute("foo", "bar")
426+
self.confirm(len(el.attributes.items()) == 2)
427+
el.removeAttribute("foo")
428+
self.confirm(len(el.attributes.items()) == 1)
429+
dom.unlink()
406430

407431
def testGetAttribute(self):
408432
dom = Document()
@@ -496,7 +520,11 @@ def testAttributeRepr(self):
496520
self.confirm(str(node) == repr(node))
497521
dom.unlink()
498522

499-
def testTextNodeRepr(self): pass
523+
def testTextNodeRepr(self):
524+
dom = Document()
525+
el = dom.appendChild(dom.createElement("foo"))
526+
self.confirm(str(el) == repr(el))
527+
dom.unlink()
500528

501529
def testWriteXML(self):
502530
str = '<?xml version="1.0" ?><a b="c"/>'
@@ -601,9 +629,21 @@ def testProcessingInstruction(self):
601629
and pi.localName is None
602630
and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE)
603631

604-
def testProcessingInstructionRepr(self): pass
632+
def testProcessingInstructionRepr(self):
633+
dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
634+
pi = dom.documentElement.firstChild
635+
string1 = str(pi.nodeType)
636+
string2 = repr(pi.nodeType)
637+
self.assertEqual(string1, string2)
605638

606-
def testTextRepr(self): pass
639+
def testTextRepr(self):
640+
dom = Document()
641+
elem = dom.createElement('elem')
642+
elem.appendChild(dom.createTextNode("foo"))
643+
el = elem.firstChild
644+
string1 = str(el)
645+
string2 = repr(el)
646+
self.assertEqual(string1, string2)
607647

608648
def testWriteText(self): pass
609649

0 commit comments

Comments
 (0)