Skip to content

test_biblexmlconverter

Test the BiblexmlConverter class.

assertXmlEqual(got, want)

Check if two xml snippets are equal.

Source code in /home/anders/projects/CorpusTools/corpustools/test/test_biblexmlconverter.py
140
141
142
143
144
145
146
147
def assertXmlEqual(got, want):
    """Check if two xml snippets are equal."""
    got = lxml.etree.tostring(got, encoding="unicode")
    want = lxml.etree.tostring(want, encoding="unicode")
    checker = lxml.doctestcompare.LXMLOutputChecker()
    if not checker.check_output(want, got, 0):
        message = checker.output_difference(doctest.Example("", want), got, 0)
        raise AssertionError(message)

check_conversion(testname, bible_xml)

Check that the bible xml is correctly converted.

Source code in /home/anders/projects/CorpusTools/corpustools/test/test_biblexmlconverter.py
156
157
158
159
160
161
162
163
164
165
166
167
def check_conversion(testname, bible_xml):
    """Check that the bible xml is correctly converted."""
    with TempDirectory() as temp_dir:
        corpusfilename = "orig/sme/bible/nt/bogus.bible.xml"
        temp_dir.write(corpusfilename, bible_xml["orig"].encode("utf8"))

        got = biblexmlconverter.convert2intermediate(
            os.path.join(temp_dir.path, corpusfilename)
        )
        want = lxml.etree.fromstring(bible_xml["converted"])

        assertXmlEqual(got, want)

test_conversion()

Test conversion of bible xml elements.

Source code in /home/anders/projects/CorpusTools/corpustools/test/test_biblexmlconverter.py
150
151
152
153
def test_conversion():
    """Test conversion of bible xml elements."""
    for testname, bible_xml in TESTS.items():
        yield check_conversion, testname, bible_xml