Esempio n. 1
0
    def test_parse_invalid_middle_line(self):
        """
        Check that an example with a separation line between command and code
        fails. The violating line should stay in the original document.
        """
        doc = []
        doc.append("<!-- APPEND /dev/null -->")
        doc.append("This caused a seg fault?")

        retval = Markdown.parse(doc)
        self.assertIsNone(retval)
        self.assertEqual(doc, [])  # lines are eaten in the second round
Esempio n. 2
0
    def test_parse_no_tag_pre(self):
        """
        Check that an pre-example without any tags fails. This sould consume all
        lines.
        """
        doc = []
        doc.append("Yeeharr, this is an example.")
        doc.append("<pre>")
        doc.append("touch /tmp")
        doc.append("touch /home")
        doc.append("</pre>")
        doc.append("This caused a seg fault?")

        retval = Markdown.parse([])
        self.assertIsNone(retval)
Esempio n. 3
0
    def test_parse_valid_pre(self):
        """
        Check that a simple pre-example runs and returns args, command and
        content.
        """
        doc = []
        doc.append("<!-- APPEND /dev/null -->")
        doc.append("<pre>")
        doc.append("touch /tmp")
        doc.append("touch /home")
        doc.append("</pre>")

        retval = Markdown.parse(doc)
        self.assertEqual(len(retval), 4)
        command, args, content, length = retval
        self.assertEqual(command, "APPEND")
        self.assertEqual(args, "/dev/null")
        self.assertEqual(content, ["touch /tmp", "touch /home"])
        self.assertEqual(length, 5)
Esempio n. 4
0
    def test_parse_valid_additional_lines_pre(self):
        """
        Check that an pre-example with unrelated lines runs and returns args,
        command and content. The inital list of lines should be modified and
        is expected to contain only the tailing lines.
        """
        doc = []
        doc.append("Yeeharr, this is an example.")
        doc.append("<!-- APPEND /dev/null -->")
        doc.append("<pre>")
        doc.append("touch /tmp")
        doc.append("touch /home")
        doc.append("</pre>")
        doc.append("This caused a seg fault?")

        retval = Markdown.parse(doc)
        self.assertEqual(len(retval), 4)
        command, args, content, length = retval
        self.assertEqual(command, "APPEND")
        self.assertEqual(args, "/dev/null")
        self.assertEqual(content, ["touch /tmp", "touch /home"])
        self.assertEqual(length, 5)
        self.assertEqual(doc, ["This caused a seg fault?"])
Esempio n. 5
0
 def test_parse_empty_input(self):
     """
     Check that an empty example fails.
     """
     retval = Markdown.parse([])
     self.assertIsNone(retval)