def test_getIfExists(self): doc1=microdom.parseString('<a><b id="bar"/><c class="foo"/></a>') node=domhelpers.getIfExists(doc1, "foo") actual=node.toxml() expected='<c class="foo"></c>' assert actual==expected, 'expected %s, got %s' % (expected, actual) node=domhelpers.getIfExists(doc1, "pzork") assert node==None, 'expected None, didn\'t get None'
def test_getIfExists(self): doc1 = microdom.parseString('<a><b id="bar"/><c class="foo"/></a>') node = domhelpers.getIfExists(doc1, "foo") actual = node.toxml() expected = '<c class="foo"></c>' assert actual == expected, 'expected %s, got %s' % (expected, actual) node = domhelpers.getIfExists(doc1, "pzork") assert node == None, 'expected None, didn\'t get None'
def test_getIfExists(self): doc1 = self.dom.parseString('<a><b id="bar"/><c class="foo"/></a>') node=domhelpers.getIfExists(doc1, "foo") actual=node.toxml() expected = self.dom.Element('c') expected.setAttribute('class', 'foo') self.assertEqual(actual, expected.toxml()) node=domhelpers.getIfExists(doc1, "pzork") self.assertIdentical(node, None)
def test_getIfExists(self): doc1 = self.dom.parseString('<a><b id="bar"/><c class="foo"/></a>') doc = self.dom.Document() node = domhelpers.getIfExists(doc1, "foo") actual = node.toxml() expected = doc.createElement("c") expected.setAttribute("class", "foo") self.assertEqual(actual, expected.toxml()) node = domhelpers.getIfExists(doc1, "pzork") self.assertIdentical(node, None)