Fred Drake | 17647f5 | 2000-07-03 16:37:42 +0000 | [diff] [blame] | 1 | # test for xml.dom.minidom |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 3 | import os |
Fred Drake | 17647f5 | 2000-07-03 16:37:42 +0000 | [diff] [blame] | 4 | import sys |
| 5 | import traceback |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 6 | |
Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 7 | from test.test_support import verbose |
Fred Drake | 17647f5 | 2000-07-03 16:37:42 +0000 | [diff] [blame] | 8 | |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 9 | import xml.dom |
| 10 | import xml.parsers.expat |
| 11 | |
| 12 | from xml.dom.minidom import parse, Node, Document, parseString |
| 13 | |
Fred Drake | 17647f5 | 2000-07-03 16:37:42 +0000 | [diff] [blame] | 14 | if __name__ == "__main__": |
| 15 | base = sys.argv[0] |
| 16 | else: |
| 17 | base = __file__ |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 18 | tstfile = os.path.join(os.path.dirname(base), "test"+os.extsep+"xml") |
Fred Drake | 17647f5 | 2000-07-03 16:37:42 +0000 | [diff] [blame] | 19 | del base |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 20 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 21 | def confirm(test, testname = "Test"): |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 22 | if not test: |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 23 | print "Failed " + testname |
| 24 | raise Exception |
| 25 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 26 | Node._debug = 1 |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 27 | |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 28 | def testParseFromFile(): |
| 29 | from StringIO import StringIO |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 30 | dom = parse(StringIO(open(tstfile).read())) |
Paul Prescod | 4c79919 | 2000-09-19 19:33:02 +0000 | [diff] [blame] | 31 | dom.unlink() |
Martin v. Löwis | 89c528b | 2000-09-19 16:22:10 +0000 | [diff] [blame] | 32 | confirm(isinstance(dom,Document)) |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 33 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 34 | def testGetElementsByTagName(): |
| 35 | dom = parse(tstfile) |
| 36 | confirm(dom.getElementsByTagName("LI") == \ |
| 37 | dom.documentElement.getElementsByTagName("LI")) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 38 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 39 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 40 | def testInsertBefore(): |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 41 | dom = parseString("<doc><foo/></doc>") |
| 42 | root = dom.documentElement |
| 43 | elem = root.childNodes[0] |
| 44 | nelem = dom.createElement("element") |
| 45 | root.insertBefore(nelem, elem) |
| 46 | confirm(len(root.childNodes) == 2 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 47 | and root.childNodes.length == 2 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 48 | and root.childNodes[0] is nelem |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 49 | and root.childNodes.item(0) is nelem |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 50 | and root.childNodes[1] is elem |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 51 | and root.childNodes.item(1) is elem |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 52 | and root.firstChild is nelem |
| 53 | and root.lastChild is elem |
| 54 | and root.toxml() == "<doc><element/><foo/></doc>" |
| 55 | , "testInsertBefore -- node properly placed in tree") |
| 56 | nelem = dom.createElement("element") |
| 57 | root.insertBefore(nelem, None) |
| 58 | confirm(len(root.childNodes) == 3 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 59 | and root.childNodes.length == 3 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 60 | and root.childNodes[1] is elem |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 61 | and root.childNodes.item(1) is elem |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 62 | and root.childNodes[2] is nelem |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 63 | and root.childNodes.item(2) is nelem |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 64 | and root.lastChild is nelem |
| 65 | and nelem.previousSibling is elem |
| 66 | and root.toxml() == "<doc><element/><foo/><element/></doc>" |
| 67 | , "testInsertBefore -- node properly placed in tree") |
| 68 | nelem2 = dom.createElement("bar") |
| 69 | root.insertBefore(nelem2, nelem) |
| 70 | confirm(len(root.childNodes) == 4 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 71 | and root.childNodes.length == 4 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 72 | and root.childNodes[2] is nelem2 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 73 | and root.childNodes.item(2) is nelem2 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 74 | and root.childNodes[3] is nelem |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 75 | and root.childNodes.item(3) is nelem |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 76 | and nelem2.nextSibling is nelem |
| 77 | and nelem.previousSibling is nelem2 |
| 78 | and root.toxml() == "<doc><element/><foo/><bar/><element/></doc>" |
| 79 | , "testInsertBefore -- node properly placed in tree") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 80 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 81 | |
Fred Drake | e50959a | 2001-12-06 04:32:18 +0000 | [diff] [blame] | 82 | def _create_fragment_test_nodes(): |
| 83 | dom = parseString("<doc/>") |
| 84 | orig = dom.createTextNode("original") |
| 85 | c1 = dom.createTextNode("foo") |
| 86 | c2 = dom.createTextNode("bar") |
| 87 | c3 = dom.createTextNode("bat") |
| 88 | dom.documentElement.appendChild(orig) |
| 89 | frag = dom.createDocumentFragment() |
| 90 | frag.appendChild(c1) |
| 91 | frag.appendChild(c2) |
| 92 | frag.appendChild(c3) |
| 93 | return dom, orig, c1, c2, c3, frag |
| 94 | |
| 95 | def testInsertBeforeFragment(): |
| 96 | dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes() |
| 97 | dom.documentElement.insertBefore(frag, None) |
| 98 | confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3), |
| 99 | "insertBefore(<fragment>, None)") |
| 100 | frag.unlink() |
| 101 | dom.unlink() |
| 102 | # |
| 103 | dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes() |
| 104 | dom.documentElement.insertBefore(frag, orig) |
| 105 | confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3, orig), |
| 106 | "insertBefore(<fragment>, orig)") |
| 107 | frag.unlink() |
| 108 | dom.unlink() |
| 109 | |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 110 | def testAppendChild(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 111 | dom = parse(tstfile) |
| 112 | dom.documentElement.appendChild(dom.createComment(u"Hello")) |
| 113 | confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") |
| 114 | confirm(dom.documentElement.childNodes[-1].data == "Hello") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 115 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 116 | |
Fred Drake | e50959a | 2001-12-06 04:32:18 +0000 | [diff] [blame] | 117 | def testAppendChildFragment(): |
| 118 | dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes() |
| 119 | dom.documentElement.appendChild(frag) |
| 120 | confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3), |
| 121 | "appendChild(<fragment>)") |
| 122 | frag.unlink() |
| 123 | dom.unlink() |
| 124 | |
| 125 | def testReplaceChildFragment(): |
| 126 | dom, orig, c1, c2, c3, frag = _create_fragment_test_nodes() |
| 127 | dom.documentElement.replaceChild(frag, orig) |
| 128 | orig.unlink() |
| 129 | confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3), |
| 130 | "replaceChild(<fragment>)") |
| 131 | frag.unlink() |
| 132 | dom.unlink() |
| 133 | |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 134 | def testLegalChildren(): |
| 135 | dom = Document() |
| 136 | elem = dom.createElement('element') |
| 137 | text = dom.createTextNode('text') |
Fredrik Lundh | f785042 | 2001-01-17 21:51:36 +0000 | [diff] [blame] | 138 | |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 139 | try: dom.appendChild(text) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 140 | except xml.dom.HierarchyRequestErr: pass |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 141 | else: |
| 142 | print "dom.appendChild didn't raise HierarchyRequestErr" |
| 143 | |
| 144 | dom.appendChild(elem) |
| 145 | try: dom.insertBefore(text, elem) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 146 | except xml.dom.HierarchyRequestErr: pass |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 147 | else: |
| 148 | print "dom.appendChild didn't raise HierarchyRequestErr" |
| 149 | |
| 150 | try: dom.replaceChild(text, elem) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 151 | except xml.dom.HierarchyRequestErr: pass |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 152 | else: |
| 153 | print "dom.appendChild didn't raise HierarchyRequestErr" |
| 154 | |
Tim Peters | 0009c4e | 2001-02-21 07:29:48 +0000 | [diff] [blame] | 155 | nodemap = elem.attributes |
Andrew M. Kuchling | bc8f72c | 2001-02-21 01:30:26 +0000 | [diff] [blame] | 156 | try: nodemap.setNamedItem(text) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 157 | except xml.dom.HierarchyRequestErr: pass |
Andrew M. Kuchling | bc8f72c | 2001-02-21 01:30:26 +0000 | [diff] [blame] | 158 | else: |
| 159 | print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr" |
| 160 | |
| 161 | try: nodemap.setNamedItemNS(text) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 162 | except xml.dom.HierarchyRequestErr: pass |
Andrew M. Kuchling | bc8f72c | 2001-02-21 01:30:26 +0000 | [diff] [blame] | 163 | else: |
| 164 | print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr" |
| 165 | |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 166 | elem.appendChild(text) |
Fredrik Lundh | f785042 | 2001-01-17 21:51:36 +0000 | [diff] [blame] | 167 | dom.unlink() |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 168 | |
Fred Drake | 2998a55 | 2001-12-06 18:27:48 +0000 | [diff] [blame] | 169 | def testNamedNodeMapSetItem(): |
| 170 | dom = Document() |
| 171 | elem = dom.createElement('element') |
| 172 | attrs = elem.attributes |
| 173 | attrs["foo"] = "bar" |
| 174 | a = attrs.item(0) |
| 175 | confirm(a.ownerDocument is dom, |
| 176 | "NamedNodeMap.__setitem__() sets ownerDocument") |
| 177 | confirm(a.ownerElement is elem, |
| 178 | "NamedNodeMap.__setitem__() sets ownerElement") |
| 179 | confirm(a.value == "bar", |
| 180 | "NamedNodeMap.__setitem__() sets value") |
| 181 | confirm(a.nodeValue == "bar", |
| 182 | "NamedNodeMap.__setitem__() sets nodeValue") |
| 183 | elem.unlink() |
| 184 | dom.unlink() |
| 185 | |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 186 | def testNonZero(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 187 | dom = parse(tstfile) |
| 188 | confirm(dom)# should not be zero |
| 189 | dom.appendChild(dom.createComment("foo")) |
| 190 | confirm(not dom.childNodes[-1].childNodes) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 191 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 192 | |
| 193 | def testUnlink(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 194 | dom = parse(tstfile) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 195 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 196 | |
| 197 | def testElement(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 198 | dom = Document() |
| 199 | dom.appendChild(dom.createElement("abc")) |
| 200 | confirm(dom.documentElement) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 201 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 202 | |
| 203 | def testAAA(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 204 | dom = parseString("<abc/>") |
| 205 | el = dom.documentElement |
| 206 | el.setAttribute("spam", "jam2") |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 207 | confirm(el.toxml() == '<abc spam="jam2"/>', "testAAA") |
Fred Drake | 2998a55 | 2001-12-06 18:27:48 +0000 | [diff] [blame] | 208 | a = el.getAttributeNode("spam") |
| 209 | confirm(a.ownerDocument is dom, |
| 210 | "setAttribute() sets ownerDocument") |
| 211 | confirm(a.ownerElement is dom.documentElement, |
| 212 | "setAttribute() sets ownerElement") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 213 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 214 | |
| 215 | def testAAB(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 216 | dom = parseString("<abc/>") |
| 217 | el = dom.documentElement |
| 218 | el.setAttribute("spam", "jam") |
| 219 | el.setAttribute("spam", "jam2") |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 220 | confirm(el.toxml() == '<abc spam="jam2"/>', "testAAB") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 221 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 222 | |
| 223 | def testAddAttr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 224 | dom = Document() |
| 225 | child = dom.appendChild(dom.createElement("abc")) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 226 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 227 | child.setAttribute("def", "ghi") |
| 228 | confirm(child.getAttribute("def") == "ghi") |
| 229 | confirm(child.attributes["def"].value == "ghi") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 230 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 231 | child.setAttribute("jkl", "mno") |
| 232 | confirm(child.getAttribute("jkl") == "mno") |
| 233 | confirm(child.attributes["jkl"].value == "mno") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 234 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 235 | confirm(len(child.attributes) == 2) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 236 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 237 | child.setAttribute("def", "newval") |
| 238 | confirm(child.getAttribute("def") == "newval") |
| 239 | confirm(child.attributes["def"].value == "newval") |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 240 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 241 | confirm(len(child.attributes) == 2) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 242 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 243 | |
| 244 | def testDeleteAttr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 245 | dom = Document() |
| 246 | child = dom.appendChild(dom.createElement("abc")) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 247 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 248 | confirm(len(child.attributes) == 0) |
| 249 | child.setAttribute("def", "ghi") |
| 250 | confirm(len(child.attributes) == 1) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 251 | del child.attributes["def"] |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 252 | confirm(len(child.attributes) == 0) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 253 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 254 | |
| 255 | def testRemoveAttr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 256 | dom = Document() |
| 257 | child = dom.appendChild(dom.createElement("abc")) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 258 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 259 | child.setAttribute("def", "ghi") |
| 260 | confirm(len(child.attributes) == 1) |
| 261 | child.removeAttribute("def") |
| 262 | confirm(len(child.attributes) == 0) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 263 | |
| 264 | dom.unlink() |
| 265 | |
| 266 | def testRemoveAttrNS(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 267 | dom = Document() |
| 268 | child = dom.appendChild( |
| 269 | dom.createElementNS("http://www.python.org", "python:abc")) |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 270 | child.setAttributeNS("http://www.w3.org", "xmlns:python", |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 271 | "http://www.python.org") |
| 272 | child.setAttributeNS("http://www.python.org", "python:abcattr", "foo") |
| 273 | confirm(len(child.attributes) == 2) |
| 274 | child.removeAttributeNS("http://www.python.org", "abcattr") |
| 275 | confirm(len(child.attributes) == 1) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 276 | |
| 277 | dom.unlink() |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 278 | |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 279 | def testRemoveAttributeNode(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 280 | dom = Document() |
| 281 | child = dom.appendChild(dom.createElement("foo")) |
| 282 | child.setAttribute("spam", "jam") |
| 283 | confirm(len(child.attributes) == 1) |
| 284 | node = child.getAttributeNode("spam") |
| 285 | child.removeAttributeNode(node) |
| 286 | confirm(len(child.attributes) == 0) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 287 | |
| 288 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 289 | |
| 290 | def testChangeAttr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 291 | dom = parseString("<abc/>") |
| 292 | el = dom.documentElement |
| 293 | el.setAttribute("spam", "jam") |
| 294 | confirm(len(el.attributes) == 1) |
| 295 | el.setAttribute("spam", "bam") |
| 296 | confirm(len(el.attributes) == 1) |
| 297 | el.attributes["spam"] = "ham" |
| 298 | confirm(len(el.attributes) == 1) |
| 299 | el.setAttribute("spam2", "bam") |
| 300 | confirm(len(el.attributes) == 2) |
| 301 | el.attributes[ "spam2"] = "bam2" |
| 302 | confirm(len(el.attributes) == 2) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 303 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 304 | |
| 305 | def testGetAttrList(): |
| 306 | pass |
| 307 | |
| 308 | def testGetAttrValues(): pass |
| 309 | |
| 310 | def testGetAttrLength(): pass |
| 311 | |
| 312 | def testGetAttribute(): pass |
| 313 | |
| 314 | def testGetAttributeNS(): pass |
| 315 | |
| 316 | def testGetAttributeNode(): pass |
| 317 | |
Martin v. Löwis | 351c3d0 | 2001-06-03 14:27:02 +0000 | [diff] [blame] | 318 | def testGetElementsByTagNameNS(): |
| 319 | d="""<foo xmlns:minidom="http://pyxml.sf.net/minidom"> |
| 320 | <minidom:myelem/> |
| 321 | </foo>""" |
| 322 | dom = parseString(d) |
| 323 | elem = dom.getElementsByTagNameNS("http://pyxml.sf.net/minidom","myelem") |
| 324 | confirm(len(elem) == 1) |
| 325 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 326 | |
| 327 | def testGetEmptyNodeListFromElementsByTagNameNS(): pass |
| 328 | |
| 329 | def testElementReprAndStr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 330 | dom = Document() |
| 331 | el = dom.appendChild(dom.createElement("abc")) |
| 332 | string1 = repr(el) |
| 333 | string2 = str(el) |
| 334 | confirm(string1 == string2) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 335 | dom.unlink() |
| 336 | |
| 337 | # commented out until Fredrick's fix is checked in |
| 338 | def _testElementReprAndStrUnicode(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 339 | dom = Document() |
| 340 | el = dom.appendChild(dom.createElement(u"abc")) |
| 341 | string1 = repr(el) |
| 342 | string2 = str(el) |
| 343 | confirm(string1 == string2) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 344 | dom.unlink() |
| 345 | |
| 346 | # commented out until Fredrick's fix is checked in |
| 347 | def _testElementReprAndStrUnicodeNS(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 348 | dom = Document() |
| 349 | el = dom.appendChild( |
| 350 | dom.createElementNS(u"http://www.slashdot.org", u"slash:abc")) |
| 351 | string1 = repr(el) |
| 352 | string2 = str(el) |
| 353 | confirm(string1 == string2) |
| 354 | confirm(string1.find("slash:abc") != -1) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 355 | dom.unlink() |
| 356 | |
| 357 | def testAttributeRepr(): |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 358 | dom = Document() |
| 359 | el = dom.appendChild(dom.createElement(u"abc")) |
| 360 | node = el.setAttribute("abc", "def") |
| 361 | confirm(str(node) == repr(node)) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 362 | dom.unlink() |
| 363 | |
| 364 | def testTextNodeRepr(): pass |
| 365 | |
Martin v. Löwis | 0a84a33 | 2000-10-06 22:42:55 +0000 | [diff] [blame] | 366 | def testWriteXML(): |
Martin v. Löwis | fe28ca0 | 2001-02-06 01:16:48 +0000 | [diff] [blame] | 367 | str = '<?xml version="1.0" ?>\n<a b="c"/>' |
Martin v. Löwis | 0a84a33 | 2000-10-06 22:42:55 +0000 | [diff] [blame] | 368 | dom = parseString(str) |
| 369 | domstr = dom.toxml() |
| 370 | dom.unlink() |
| 371 | confirm(str == domstr) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 372 | |
| 373 | def testProcessingInstruction(): pass |
| 374 | |
| 375 | def testProcessingInstructionRepr(): pass |
| 376 | |
| 377 | def testTextRepr(): pass |
| 378 | |
| 379 | def testWriteText(): pass |
| 380 | |
| 381 | def testDocumentElement(): pass |
| 382 | |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 383 | def testTooManyDocumentElements(): |
| 384 | doc = parseString("<doc/>") |
| 385 | elem = doc.createElement("extra") |
| 386 | try: |
| 387 | doc.appendChild(elem) |
Fred Drake | c441f7b | 2002-07-19 22:16:41 +0000 | [diff] [blame] | 388 | except xml.dom.HierarchyRequestErr: |
| 389 | pass |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 390 | else: |
| 391 | print "Failed to catch expected exception when" \ |
| 392 | " adding extra document element." |
| 393 | elem.unlink() |
| 394 | doc.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 395 | |
| 396 | def testCreateElementNS(): pass |
| 397 | |
Andrew M. Kuchling | ad4a558 | 2000-12-31 04:03:27 +0000 | [diff] [blame] | 398 | def testCreateAttributeNS(): pass |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 399 | |
| 400 | def testParse(): pass |
| 401 | |
| 402 | def testParseString(): pass |
| 403 | |
| 404 | def testComment(): pass |
| 405 | |
| 406 | def testAttrListItem(): pass |
| 407 | |
| 408 | def testAttrListItems(): pass |
| 409 | |
| 410 | def testAttrListItemNS(): pass |
| 411 | |
| 412 | def testAttrListKeys(): pass |
| 413 | |
| 414 | def testAttrListKeysNS(): pass |
| 415 | |
| 416 | def testAttrListValues(): pass |
| 417 | |
| 418 | def testAttrListLength(): pass |
| 419 | |
| 420 | def testAttrList__getitem__(): pass |
| 421 | |
| 422 | def testAttrList__setitem__(): pass |
| 423 | |
| 424 | def testSetAttrValueandNodeValue(): pass |
| 425 | |
| 426 | def testParseElement(): pass |
| 427 | |
| 428 | def testParseAttributes(): pass |
| 429 | |
| 430 | def testParseElementNamespaces(): pass |
| 431 | |
| 432 | def testParseAttributeNamespaces(): pass |
| 433 | |
| 434 | def testParseProcessingInstructions(): pass |
| 435 | |
| 436 | def testChildNodes(): pass |
| 437 | |
| 438 | def testFirstChild(): pass |
| 439 | |
| 440 | def testHasChildNodes(): pass |
| 441 | |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 442 | def testCloneElementShallow(): |
| 443 | dom, clone = _setupCloneElement(0) |
| 444 | confirm(len(clone.childNodes) == 0 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 445 | and clone.childNodes.length == 0 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 446 | and clone.parentNode is None |
| 447 | and clone.toxml() == '<doc attr="value"/>' |
| 448 | , "testCloneElementShallow") |
| 449 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 450 | |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 451 | def testCloneElementDeep(): |
| 452 | dom, clone = _setupCloneElement(1) |
| 453 | confirm(len(clone.childNodes) == 1 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 454 | and clone.childNodes.length == 1 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 455 | and clone.parentNode is None |
| 456 | and clone.toxml() == '<doc attr="value"><foo/></doc>' |
| 457 | , "testCloneElementDeep") |
| 458 | dom.unlink() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 459 | |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 460 | def _setupCloneElement(deep): |
| 461 | dom = parseString("<doc attr='value'><foo/></doc>") |
| 462 | root = dom.documentElement |
| 463 | clone = root.cloneNode(deep) |
| 464 | _testCloneElementCopiesAttributes( |
| 465 | root, clone, "testCloneElement" + (deep and "Deep" or "Shallow")) |
| 466 | # mutilate the original so shared data is detected |
| 467 | root.tagName = root.nodeName = "MODIFIED" |
| 468 | root.setAttribute("attr", "NEW VALUE") |
| 469 | root.setAttribute("added", "VALUE") |
| 470 | return dom, clone |
| 471 | |
| 472 | def _testCloneElementCopiesAttributes(e1, e2, test): |
| 473 | attrs1 = e1.attributes |
| 474 | attrs2 = e2.attributes |
| 475 | keys1 = attrs1.keys() |
| 476 | keys2 = attrs2.keys() |
| 477 | keys1.sort() |
| 478 | keys2.sort() |
| 479 | confirm(keys1 == keys2, "clone of element has same attribute keys") |
| 480 | for i in range(len(keys1)): |
| 481 | a1 = attrs1.item(i) |
| 482 | a2 = attrs2.item(i) |
| 483 | confirm(a1 is not a2 |
| 484 | and a1.value == a2.value |
| 485 | and a1.nodeValue == a2.nodeValue |
| 486 | and a1.namespaceURI == a2.namespaceURI |
| 487 | and a1.localName == a2.localName |
| 488 | , "clone of attribute node has proper attribute values") |
| 489 | confirm(a2.ownerElement is e2, |
| 490 | "clone of attribute node correctly owned") |
Fredrik Lundh | f785042 | 2001-01-17 21:51:36 +0000 | [diff] [blame] | 491 | |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 492 | |
| 493 | def testCloneDocumentShallow(): pass |
| 494 | |
| 495 | def testCloneDocumentDeep(): pass |
| 496 | |
| 497 | def testCloneAttributeShallow(): pass |
| 498 | |
| 499 | def testCloneAttributeDeep(): pass |
| 500 | |
| 501 | def testClonePIShallow(): pass |
| 502 | |
| 503 | def testClonePIDeep(): pass |
| 504 | |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 505 | def testNormalize(): |
| 506 | doc = parseString("<doc/>") |
| 507 | root = doc.documentElement |
| 508 | root.appendChild(doc.createTextNode("first")) |
| 509 | root.appendChild(doc.createTextNode("second")) |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 510 | confirm(len(root.childNodes) == 2 |
| 511 | and root.childNodes.length == 2, "testNormalize -- preparation") |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 512 | doc.normalize() |
| 513 | confirm(len(root.childNodes) == 1 |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 514 | and root.childNodes.length == 1 |
Fred Drake | a1bde80 | 2000-11-21 22:02:43 +0000 | [diff] [blame] | 515 | and root.firstChild is root.lastChild |
| 516 | and root.firstChild.data == "firstsecond" |
| 517 | , "testNormalize -- result") |
| 518 | doc.unlink() |
| 519 | |
Fred Drake | 3277da0 | 2000-12-14 18:20:22 +0000 | [diff] [blame] | 520 | doc = parseString("<doc/>") |
| 521 | root = doc.documentElement |
| 522 | root.appendChild(doc.createTextNode("")) |
| 523 | doc.normalize() |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 524 | confirm(len(root.childNodes) == 0 |
| 525 | and root.childNodes.length == 0, |
Fred Drake | 3277da0 | 2000-12-14 18:20:22 +0000 | [diff] [blame] | 526 | "testNormalize -- single empty node removed") |
| 527 | doc.unlink() |
| 528 | |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 529 | def testSiblings(): |
| 530 | doc = parseString("<doc><?pi?>text?<elm/></doc>") |
| 531 | root = doc.documentElement |
| 532 | (pi, text, elm) = root.childNodes |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 533 | |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 534 | confirm(pi.nextSibling is text and |
| 535 | pi.previousSibling is None and |
| 536 | text.nextSibling is elm and |
| 537 | text.previousSibling is pi and |
| 538 | elm.nextSibling is None and |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 539 | elm.previousSibling is text, "testSiblings") |
| 540 | |
| 541 | doc.unlink() |
| 542 | |
| 543 | def testParents(): |
| 544 | doc = parseString("<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>") |
| 545 | root = doc.documentElement |
| 546 | elm1 = root.childNodes[0] |
| 547 | (elm2a, elm2b) = elm1.childNodes |
| 548 | elm3 = elm2b.childNodes[0] |
| 549 | |
| 550 | confirm(root.parentNode is doc and |
| 551 | elm1.parentNode is root and |
| 552 | elm2a.parentNode is elm1 and |
| 553 | elm2b.parentNode is elm1 and |
| 554 | elm3.parentNode is elm2b, "testParents") |
| 555 | |
| 556 | doc.unlink() |
| 557 | |
Fred Drake | 946f7b1 | 2001-09-28 20:31:50 +0000 | [diff] [blame] | 558 | def testNodeListItem(): |
| 559 | doc = parseString("<doc><e/><e/></doc>") |
| 560 | children = doc.childNodes |
| 561 | docelem = children[0] |
| 562 | confirm(children[0] is children.item(0) |
| 563 | and children.item(1) is None |
| 564 | and docelem.childNodes.item(0) is docelem.childNodes[0] |
| 565 | and docelem.childNodes.item(1) is docelem.childNodes[1] |
| 566 | and docelem.childNodes.item(0).childNodes.item(0) is None, |
| 567 | "test NodeList.item()") |
| 568 | doc.unlink() |
| 569 | |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 570 | def testSAX2DOM(): |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 571 | from xml.dom import pulldom |
| 572 | |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 573 | sax2dom = pulldom.SAX2DOM() |
| 574 | sax2dom.startDocument() |
| 575 | sax2dom.startElement("doc", {}) |
| 576 | sax2dom.characters("text") |
| 577 | sax2dom.startElement("subelm", {}) |
| 578 | sax2dom.characters("text") |
| 579 | sax2dom.endElement("subelm") |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 580 | sax2dom.characters("text") |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 581 | sax2dom.endElement("doc") |
| 582 | sax2dom.endDocument() |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 583 | |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 584 | doc = sax2dom.document |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 585 | root = doc.documentElement |
| 586 | (text1, elm1, text2) = root.childNodes |
| 587 | text3 = elm1.childNodes[0] |
| 588 | |
| 589 | confirm(text1.previousSibling is None and |
| 590 | text1.nextSibling is elm1 and |
| 591 | elm1.previousSibling is text1 and |
| 592 | elm1.nextSibling is text2 and |
| 593 | text2.previousSibling is elm1 and |
| 594 | text2.nextSibling is None and |
| 595 | text3.previousSibling is None and |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 596 | text3.nextSibling is None, "testSAX2DOM - siblings") |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 597 | |
| 598 | confirm(root.parentNode is doc and |
| 599 | text1.parentNode is root and |
| 600 | elm1.parentNode is root and |
| 601 | text2.parentNode is root and |
Lars Gustäbel | 5bad5a4 | 2000-10-13 20:54:10 +0000 | [diff] [blame] | 602 | text3.parentNode is elm1, "testSAX2DOM - parents") |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 603 | |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 604 | doc.unlink() |
| 605 | |
Martin v. Löwis | 7d650ca | 2002-06-30 15:05:00 +0000 | [diff] [blame] | 606 | def testEncodings(): |
| 607 | doc = parseString('<foo>€</foo>') |
| 608 | confirm(doc.toxml() == u'<?xml version="1.0" ?>\n<foo>\u20ac</foo>' |
| 609 | and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?>\n<foo>\xe2\x82\xac</foo>' |
| 610 | and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?>\n<foo>\xa4</foo>', |
| 611 | "testEncodings - encoding EURO SIGN") |
| 612 | doc.unlink() |
| 613 | |
Lars Gustäbel | f27f5ab | 2000-10-11 22:36:00 +0000 | [diff] [blame] | 614 | # --- MAIN PROGRAM |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 615 | |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 616 | names = globals().keys() |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 617 | names.sort() |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 618 | |
Fred Drake | acfb3f6 | 2001-02-01 18:11:29 +0000 | [diff] [blame] | 619 | failed = [] |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 620 | |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 621 | for name in names: |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 622 | if name.startswith("test"): |
| 623 | func = globals()[name] |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 624 | try: |
| 625 | func() |
Fred Drake | ebe7302 | 2000-10-09 19:57:39 +0000 | [diff] [blame] | 626 | confirm(len(Node.allnodes) == 0, |
| 627 | "assertion: len(Node.allnodes) == 0") |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 628 | if len(Node.allnodes): |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 629 | print "Garbage left over:" |
Martin v. Löwis | 89c528b | 2000-09-19 16:22:10 +0000 | [diff] [blame] | 630 | if verbose: |
| 631 | print Node.allnodes.items()[0:10] |
| 632 | else: |
| 633 | # Don't print specific nodes if repeatable results |
| 634 | # are needed |
| 635 | print len(Node.allnodes) |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 636 | Node.allnodes = {} |
Fred Drake | acfb3f6 | 2001-02-01 18:11:29 +0000 | [diff] [blame] | 637 | except: |
| 638 | failed.append(name) |
Paul Prescod | 7993bcc | 2000-07-01 14:54:16 +0000 | [diff] [blame] | 639 | print "Test Failed: ", name |
Fred Drake | 1703cf6 | 2000-12-15 21:31:59 +0000 | [diff] [blame] | 640 | sys.stdout.flush() |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 641 | traceback.print_exception(*sys.exc_info()) |
Fred Drake | acfb3f6 | 2001-02-01 18:11:29 +0000 | [diff] [blame] | 642 | print `sys.exc_info()[1]` |
Jeremy Hylton | 3b0c600 | 2000-10-12 17:31:36 +0000 | [diff] [blame] | 643 | Node.allnodes = {} |
Paul Prescod | 10d2766 | 2000-09-18 19:07:26 +0000 | [diff] [blame] | 644 | |
Fred Drake | acfb3f6 | 2001-02-01 18:11:29 +0000 | [diff] [blame] | 645 | if failed: |
| 646 | print "\n\n\n**** Check for failures in these tests:" |
| 647 | for name in failed: |
| 648 | print " " + name |