def test_render_rst_with_code(self): node = Usage(7) child_a = Node(indent=10, lines=['print("Hello, World!")'], parent=node) node.add_child(child_a) child_b = Node(indent=10, lines=['print("Reticulating splines!")'], parent=node) node.add_child(child_b) rst = node.render_rst() self.assertEqual(rst, [' .. rubric:: Usage:', '', ' .. code-block:: python', '', ' print("Hello, World!")', ' print("Reticulating splines!")', ''])
def test_render_rst_with_indented_code(self): node = Usage(5) child_a = Node(indent=10, lines=['for i in range(100):'], parent=node) node.add_child(child_a) child_b = Node(indent=14, lines=['print(i)'], parent=node) node.add_child(child_b) rst = node.render_rst() self.assertEqual(rst, [' .. rubric:: Usage:', '', ' .. code-block:: python', '', ' for i in range(100):', ' print(i)', ''])
def test_render_rst_empty(self): node = Usage(5) rst = node.render_rst() self.assertEqual(rst, [])