Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(161340)

Delta Between Two Patch Sets: Lib/test/test_minidom.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 6 years, 3 months ago
Right Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_memoryview.py ('k') | Lib/test/test_module.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # test for xml.dom.minidom 1 # test for xml.dom.minidom
2 2
3 import pickle 3 import pickle
4 from test.support import verbose, run_unittest, findfile 4 from test.support import run_unittest, findfile
5 import unittest 5 import unittest
6 6
7 import xml.dom.minidom 7 import xml.dom.minidom
8 8
9 from xml.dom.minidom import parse, Node, Document, parseString 9 from xml.dom.minidom import parse, Node, Document, parseString
10 from xml.dom.minidom import getDOMImplementation 10 from xml.dom.minidom import getDOMImplementation
11 11
12 12
13 tstfile = findfile("test.xml", subdir="xmltestdata") 13 tstfile = findfile("test.xml", subdir="xmltestdata")
14 14
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 child = dom.appendChild(dom.createElement("foo")) 303 child = dom.appendChild(dom.createElement("foo"))
304 child.setAttribute("spam", "jam") 304 child.setAttribute("spam", "jam")
305 self.confirm(len(child.attributes) == 1) 305 self.confirm(len(child.attributes) == 1)
306 node = child.getAttributeNode("spam") 306 node = child.getAttributeNode("spam")
307 self.assertRaises(xml.dom.NotFoundErr, child.removeAttributeNode, 307 self.assertRaises(xml.dom.NotFoundErr, child.removeAttributeNode,
308 None) 308 None)
309 child.removeAttributeNode(node) 309 child.removeAttributeNode(node)
310 self.confirm(len(child.attributes) == 0 310 self.confirm(len(child.attributes) == 0
311 and child.getAttributeNode("spam") is None) 311 and child.getAttributeNode("spam") is None)
312 dom2 = Document() 312 dom2 = Document()
313 child2 = dom2.appendChild(dom.createElement("foo")) 313 child2 = dom2.appendChild(dom2.createElement("foo"))
314 self.assertRaises(xml.dom.NotFoundErr, child.removeAttributeNode, 314 node2 = child2.getAttributeNode("spam")
315 node) 315 self.assertRaises(xml.dom.NotFoundErr, child2.removeAttributeNode,
316 node2)
316 dom.unlink() 317 dom.unlink()
317 318
318 def testHasAttribute(self): 319 def testHasAttribute(self):
319 dom = Document() 320 dom = Document()
320 child = dom.appendChild(dom.createElement("foo")) 321 child = dom.appendChild(dom.createElement("foo"))
321 child.setAttribute("spam", "jam") 322 child.setAttribute("spam", "jam")
322 self.confirm(child.hasAttribute("spam")) 323 self.confirm(child.hasAttribute("spam"))
323 324
324 def testChangeAttr(self): 325 def testChangeAttr(self):
325 dom = parseString("<abc/>") 326 dom = parseString("<abc/>")
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 601
601 def testParseProcessingInstructions(self): pass 602 def testParseProcessingInstructions(self): pass
602 603
603 def testChildNodes(self): pass 604 def testChildNodes(self): pass
604 605
605 def testFirstChild(self): pass 606 def testFirstChild(self): pass
606 607
607 def testHasChildNodes(self): 608 def testHasChildNodes(self):
608 dom = parseString("<doc><foo/></doc>") 609 dom = parseString("<doc><foo/></doc>")
609 doc = dom.documentElement 610 doc = dom.documentElement
610 self.assertTrue(dom.hasChildNodes()) 611 self.assertTrue(doc.hasChildNodes())
611 dom2 = parseString("<doc/>") 612 dom2 = parseString("<doc/>")
612 doc2 = dom2.documentElement 613 doc2 = dom2.documentElement
613 self.assertFalse(doc2.hasChildNodes()) 614 self.assertFalse(doc2.hasChildNodes())
614 615
615 def _testCloneElementCopiesAttributes(self, e1, e2, test): 616 def _testCloneElementCopiesAttributes(self, e1, e2, test):
616 attrs1 = e1.attributes 617 attrs1 = e1.attributes
617 attrs2 = e2.attributes 618 attrs2 = e2.attributes
618 keys1 = list(attrs1.keys()) 619 keys1 = list(attrs1.keys())
619 keys2 = list(attrs2.keys()) 620 keys2 = list(attrs2.keys())
620 keys1.sort() 621 keys1.sort()
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 num_children_before = len(doc.childNodes) 1525 num_children_before = len(doc.childNodes)
1525 doc.removeChild(doc.childNodes[0]) 1526 doc.removeChild(doc.childNodes[0])
1526 num_children_after = len(doc.childNodes) 1527 num_children_after = len(doc.childNodes)
1527 self.assertEqual(num_children_after, num_children_before - 1) 1528 self.assertEqual(num_children_after, num_children_before - 1)
1528 1529
1529 def test_main(): 1530 def test_main():
1530 run_unittest(MinidomTest) 1531 run_unittest(MinidomTest)
1531 1532
1532 if __name__ == "__main__": 1533 if __name__ == "__main__":
1533 test_main() 1534 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+