def strip_markup_test(self):
        """Test strip_markup."""

        # list of tuples representing a markup and its correct parsing
        markups = [
            ("", ""),
            ("a", "a"),
            ("č", "č"),
            ("<č>", ""),
            ("<a>", ""),
            ("<a><a>", ""),
            ("<a></a>", ""),
            ("<a>abc</a>", "abc"),
            ("<abc", ""),  # unclosed tag
            ("a>bc", "a>bc"),  # not a valid tag
            ("<i><b>bold</b></i>", "bold"),  # nesting
            ("<p><b>bold</b> <i>italic</i></p>", "bold italic"),
            ("  <a>text</a>", "  text"),
            (" <a> </a> ", "   "),
            ('<span color="blue">text</span>', 'text'),
            ("<<<<<<<<<<<<<<<", ""),
        ]

        # check if markup is parsed properly
        for markup, output in markups:
            self.assertEqual(iutil.strip_markup(markup), output)
Exemplo n.º 2
0
    def strip_markup_test(self):
        """Test strip_markup."""

        # list of tuples representing a markup and its correct parsing
        markups = [
            ("", ""),
            ("a", "a"),
            ("č", "č"),
            ("<č>", ""),
            ("<a>", ""),
            ("<a><a>", ""),
            ("<a></a>", ""),
            ("<a>abc</a>", "abc"),
            ("<abc", ""),  # unclosed tag
            ("a>bc", "a>bc"),  # not a valid tag
            ("<i><b>bold</b></i>", "bold"),  # nesting
            ("<p><b>bold</b> <i>italic</i></p>", "bold italic"),
            ("  <a>text</a>", "  text"),
            (" <a> </a> ", "   "),
            ('<span color="blue">text</span>', 'text'),
            ("<<<<<<<<<<<<<<<", ""),
        ]

        # check if markup is parsed properly
        for markup, output in markups:
            self.assertEqual(iutil.strip_markup(markup), output)
    def set_text(self, txt):
        if not self.drawn:
            self._setupScreen()

        if len(txt) > self.width:
            txt = txt[:self.width]
        else:
            spaces = (self.width - len(txt)) / 2
            txt = (" " * spaces) + txt

        self.label.setText(strip_markup(txt))
        self.processEvents()
 def set_text(self, txt):
     if not self.drawn:
         self._setupScreen()
     
     if len(txt) > self.width:
         txt = txt[:self.width]
     else:
         spaces = (self.width - len(txt)) / 2
         txt = (" " * spaces) + txt
     
     self.label.setText(strip_markup(txt))
     self.processEvents()
    def set_label(self, txt):
        if not self.drawn:
            self._setupScreen()

        self.info.setText(strip_markup(txt))
        self.processEvents()
 def set_label(self, txt):
     if not self.drawn:
         self._setupScreen()
     
     self.info.setText(strip_markup(txt))
     self.processEvents()