Did I find the right examples for you? yes no

All Samples(26)  |  Call(26)  |  Derive(0)  |  Import(0)
A useful XML comparison routine for test cases, error reports, etc.

        def check_xml(result, expected):
    '''
    A useful XML comparison routine for test cases, error reports, etc.
    '''
    diff = xml_diff(result, expected)
    diff = '\n'.join(diff)
    assert not diff, "Expected=%r\nresult=%r\ndiff=%r" % (expected, result, diff)
        


src/a/m/Amara-2.0.0/test/tree/test_mutation.py   Amara(Download)
    #doc.xml_first_child.xml_attributes[None, u'y'] = attr_x
    doc2.xml_first_child.xml_attributes.setnode(attr_x)
    treecompare.check_xml(doc2.xml_encode(), XMLDECL+EXPECTED)
    return
 
    attr_z = tree.attribute(None, u'z')
    doc.xml_first_child.xml_attributes.setnode(attr_z)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
    return
 
    del doc.xml_first_child.xml_attributes[None, u'x']
    doc.xml_first_child.xml_attributes.setnode(attr_x)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
    return
 
    attr_x = doc.xml_first_child.xml_attributes.getnode(BOGUS_X_NS, u'x')
    doc2.xml_first_child.xml_attributes.setnode(attr_x)
    treecompare.check_xml(doc2.xml_encode(), XMLDECL+EXPECTED)
    return
 
    attr_z = tree.attribute(BOGUS_X_NS, u'ns:z')
    doc.xml_first_child.xml_attributes.setnode(attr_z)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
    return
 

src/a/m/Amara-2.0.0/test/bindery/test_mutation.py   Amara(Download)
def test_simple_attr_update1():
    EXPECTED = """<a x="2"/>"""
    doc = bindery.parse('<a x="1"/>')
    doc.a.x = unicode(int(doc.a.x)+1)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
def test_simple_attr_update2():
    EXPECTED = """<a xmlns="urn:bogus:x" x="2"/>"""
    doc = bindery.parse('<a xmlns="urn:bogus:x" x="1"/>')
    doc.a.x = unicode(int(doc.a.x)+1)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
def test_simple_attr_update3():
    EXPECTED = """<n:a xmlns:n="urn:bogus:x" x="2"/>"""
    doc = bindery.parse('<n:a xmlns:n="urn:bogus:x" x="1"/>')
    doc.a.x = unicode(int(doc.a.x)+1)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
    doc.spam.xml_append_fragment('<eggs eggs="1"/>')
    doc.spam.xml_append_fragment('<eggs eggs="2"/>')
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)
    result = [ k for k in doc.spam.eggs if 'eggs' in dir(k) ]
    assert len(result) == 2, result

src/a/m/Amara-2.0.0/test/pushtree/test_pushtree.py   Amara(Download)
 
    for result, expected in zip(results, EXPECTED):
        treecompare.check_xml(result.xml_encode(), XMLDECL+expected)
    return
 
 
    for result, expected in zip(results, EXPECTED):
        treecompare.check_xml(result.xml_encode(), XMLDECL+expected)
 
    return
 
    for result, expected in zip(results, EXPECTED):
        treecompare.check_xml(result.xml_encode(), XMLDECL+expected)
 
    return
 
    for result, expected in zip(results, EXPECTED):
        treecompare.check_xml(result.xml_encode(), XMLDECL+expected)
 
    return
 
    for result, expected in zip(results, EXPECTED):
        treecompare.check_xml(result.xml_encode(), XMLDECL+expected)
    return
 

src/a/m/Amara-2.0.0/test/writers/test_struct.py   Amara(Download)
    f.close()
    result = output.read()
    treecompare.check_xml(result, XMLDECL+EXPECTED)
    return
 
    f.close()
    result = output.read()
    treecompare.check_xml(result, XMLDECL+EXPECTED)
    return
 
    f.close()
    result = output.read()
    treecompare.check_xml(result, XMLDECL+EXPECTED)
    return
 
    f.close()
    result = output.read()
    treecompare.check_xml(result, XMLDECL+EXPECTED)
    return
 
    f.close()
    result = output.read()
    treecompare.check_xml(result, XMLDECL+EXPECTED)
    return
 

src/a/m/Amara-2.0.0/test/bindery/test_html.py   Amara(Download)
    #import sys; print >> sys.stderr, doc.xml_select(u'//div[@id="content"]')[0].xml_first_child
    first_h1 = doc.xml_select(u'//div[@id="content"]//h1')[0]
    treecompare.check_xml(first_h1.xml_encode(), EXPECTED)
    assert first_h1.id == u'akara:metadata', (first_h1.id, u'akara:metadata')
    return
    #first_h1 = content.xml_select(u'.//h1')[0]
    first_h1 = doc.xml_select(u'//h:div[@id="content"]//h:h1')[0]
    treecompare.check_xml(first_h1.xml_encode(), EXPECTED)
    assert first_h1.id == u'akara:metadata', (first_h1.id, u'akara:metadata')
    return
def test_simple_attr_update3():
    EXPECTED = """<html xmlns="http://www.w3.org/1999/xhtml"><head><title>HELLO</title></head><body><p>WORLD</body></html>"""
    doc = html.parse('<n:a xmlns:n="urn:bogus:x" x="1"/>')
    doc.a.x = unicode(int(doc.a.x)+1)
    treecompare.check_xml(doc.xml_encode(), XMLDECL+EXPECTED)