コード例 #1
0
ファイル: test_parsing.py プロジェクト: symbolist/XBlock
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()
コード例 #2
0
ファイル: test_parsing.py プロジェクト: Jianbinma/XBlock
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()
コード例 #3
0
 def setUp(self):
     super(XmlTest, self).setUp()
     self.runtime = ToyRuntime()
コード例 #4
0
ファイル: test_parsing.py プロジェクト: Jianbinma/XBlock
 def setUp(self):
     super(XmlTest, self).setUp()
     self.runtime = ToyRuntime()