Exemplo n.º 1
0
    def test_re_decode(self):
        """ Test re-decoding objects working properly. """

        for (om, xml) in object_examples:
            xn = decode_xml(encode_xml(decode_xml(etree.fromstring(xml))))

            self.assertEqual(om, xn, 'decode(encode(decode(xml))) === om')
Exemplo n.º 2
0
    def test_re_decode(self):
        """ Test re-decoding objects working properly. """

        for (om, xml) in object_examples:
            xn = decode_xml(encode_xml(decode_xml(etree.fromstring(xml))))

            self.assertEqual(om, xn, 'decode(encode(decode(xml))) === om')
Exemplo n.º 3
0
    def test_re_encode(self):
        """ Test re-encoding objects working properly. """

        for (om, xml) in object_examples:
            omx = encode_xml(decode_xml(encode_xml(om)))
            xn = etree.fromstring(xml)

            self.assertTrue(elements_equal(omx, xn), 'encode(decode(encode(om))) === xml')
Exemplo n.º 4
0
    def test_re_encode(self):
        """ Test re-encoding objects working properly. """

        for (om, xml) in object_examples:
            omx = encode_xml(decode_xml(encode_xml(om)))
            xn = etree.fromstring(xml)

            self.assertTrue(elements_equal(omx, xn),
                            'encode(decode(encode(om))) === xml')
Exemplo n.º 5
0
    def test_example(self):
        """ Tests the decoder based on an example. """

        # try to parse the xml
        with open(os.path.join(os.path.dirname(__file__), 'example.om')) as f:
            xmlnode = etree.fromstring(f.read())

        omnode = decode_xml(xmlnode)

        # and check that they are as expected
        self.assertEqual(omnode, expected, "Decoding an OpenMath object")
Exemplo n.º 6
0
    def test_example(self):
        """ Tests the decoder based on an example. """

        # try to parse the xml
        with open(os.path.join(os.path.dirname(__file__), 'example.om')) as f:
            xmlnode = etree.fromstring(f.read())

        omnode = decode_xml(xmlnode)

        # and check that they are as expected
        self.assertEqual(omnode, expected, "Decoding an OpenMath object")
Exemplo n.º 7
0
from openmath.openmath import OMObject, OMInteger
from openmath.encoder import encode_xml
from openmath.decoder import decode_xml

from lxml import etree

with open("tests/example.om") as f:
    xml = etree.fromstring(str(f.read()))

# try to decode the xml
node = decode_xml(xml)

# print it
print(node)

# check if encode / decode works properly.
print(decode_xml(encode_xml(node)) == node)

obj = OMObject(OMInteger(42))
print(etree.tostring(encode_xml(obj)))
Exemplo n.º 8
0
from openmath.openmath import OMObject, OMInteger
from openmath.encoder import encode_xml
from openmath.decoder import decode_xml

from lxml import etree

with open("tests/example.om") as f:
    xml = etree.fromstring(str(f.read()))

# try to decode the xml
node = decode_xml(xml)

# print it
print(node)

# check if encode / decode works properly.
print(decode_xml(encode_xml(node)) == node)


obj = OMObject(OMInteger(42))
print(etree.tostring(encode_xml(obj)))