def test_transition_levels(self): # Make the XML xml, deps = rst2xml( b'Intro\n\n====\n\nLevel 1\n\n====\n\nLevel 1\n\n----\n\nLevel 2\n\n' b'....\n\nLevel 3\n\n----\n\nLevel 2\n\n....\n\nLevel 3\n\n' b'====\n\nLevel 1') target_start = ( b'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE document PUBLIC "+' b'//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" ' b'"http://docutils.sourceforge.net/docs/ref/docutils.dtd">\n') target_end = ( b'<document source="<string>"><paragraph>Intro</paragraph>' b'<transition level="1"></transition><paragraph>Level 1</paragraph>' b'<transition level="1"></transition><paragraph>Level 1</paragraph>' b'<transition level="2"></transition><paragraph>Level 2</paragraph>' b'<transition level="3"></transition><paragraph>Level 3</paragraph>' b'<transition level="2"></transition><paragraph>Level 2</paragraph>' b'<transition level="3"></transition><paragraph>Level 3</paragraph>' b'<transition level="1"></transition><paragraph>Level 1</paragraph>' b'</document>') self.assertTrue(xml.startswith(target_start)) self.assertTrue(xml.endswith(target_end)) # Make the slides: tree = SlideMaker(etree.fromstring(xml)).walk() target = ( b'<document source="<string>"><paragraph>Intro</paragraph>' b'<step class="step step-level-1" step="0"><paragraph>Level 1</paragraph></step>' b'<step class="step step-level-1" step="1"><paragraph>Level 1</paragraph>' b'<step class="step step-level-2" step="2"><paragraph>Level 2</paragraph>' b'<step class="step step-level-3" step="3"><paragraph>Level 3</paragraph></step>' b'</step><step class="step step-level-2" step="4"><paragraph>Level 2</paragraph>' b'<step class="step step-level-3" step="5"><paragraph>Level 3</paragraph></step>' b'</step></step><step class="step step-level-1" step="6"><paragraph>Level 1' b'</paragraph></step></document>' ) self.assertEqual(etree.tostring(tree), target)
def make_tree(file_name): """Loads reStructuredText, outputs an lxml tree""" rst = resource_string(__name__, os.path.join('test_data', file_name)) xml = rst2xml(rst) return SlideMaker(etree.fromstring(xml)).walk()
def make_tree(file_name): """Loads reStructuredText, outputs an lxml tree""" rst = resource_string(__name__, file_name) xml, dependencies = rst2xml(rst) return etree.fromstring(xml)
def make_tree(file_name): """Loads reStructuredText, outputs an lxml tree""" rst = resource_string(__name__, os.path.join('test_data', file_name)) xml, deps = rst2xml(rst) return SlideMaker(etree.fromstring(xml)).walk()