Exemplo n.º 1
0
class XmlTest(object):
    """Helpful things for XML tests."""
    def setUp(self):
        super(XmlTest, self).setUp()
        self.runtime = ToyRuntime()

    def parse_xml_to_block(self, xml):
        """A helper to get a block from some XML."""

        # ToyRuntime has an id_generator, but most runtimes won't
        # (because the generator will be contextual), so we
        # pass it explicitly to parse_xml_string.
        usage_id = self.runtime.parse_xml_string(xml,
                                                 self.runtime.id_generator)
        block = self.runtime.get_block(usage_id)
        return block

    def export_xml_for_block(self, block):
        """A helper to return the XML string for a block."""
        output = StringIO.StringIO()
        self.runtime.export_to_xml(block, output)
        return output.getvalue()
Exemplo n.º 2
0
class XmlTest(object):
    """Helpful things for XML tests."""

    def setUp(self):
        super(XmlTest, self).setUp()
        self.runtime = ToyRuntime()

    def parse_xml_to_block(self, xml):
        """A helper to get a block from some XML."""

        # ToyRuntime has an id_generator, but most runtimes won't
        # (because the generator will be contextual), so we
        # pass it explicitly to parse_xml_string.
        usage_id = self.runtime.parse_xml_string(xml, self.runtime.id_generator)
        block = self.runtime.get_block(usage_id)
        return block

    def export_xml_for_block(self, block):
        """A helper to return the XML string for a block."""
        output = StringIO.StringIO()
        self.runtime.export_to_xml(block, output)
        return output.getvalue()
Exemplo n.º 3
0
 def setUp(self):
     super(XmlTest, self).setUp()
     self.runtime = ToyRuntime()
Exemplo n.º 4
0
 def setUp(self):
     super(XmlTest, self).setUp()
     self.runtime = ToyRuntime()