def test_title_containing_formatting(self):
     """Test that title is correct when there was already formatting marks
        (internal formatting shall be removed)
     """
     test_str = "test " + Color.BOLD + "bold" + Color.END + " str"
     formatted_str = PrintFormatter.title(test_str)
     self.assertEqual(formatted_str, "\n\033[1mTEST BOLD STR\033[0m\n")
 def test_paragraphsub_ends_with_line_breaks(self):
     """Test that the result ends with a line break"""
     test_str = "test str"
     formatted_str = PrintFormatter.paragraphsub(test_str)
     str_length = len(formatted_str)
     self.assertTrue(str_length > 2)
     self.assertEqual(formatted_str[str_length - 1], '\n')
 def test_title_is_bold(self):
     """Test that the result format is surrounded by bold commands"""
     test_str = "test str"
     formatted_str = PrintFormatter.title(test_str)
     str_length = len(formatted_str)
     self.assertTrue(str_length > 8)
     self.assertEqual(formatted_str.find('\033[1m'), 1)
     self.assertEqual(formatted_str.find('\033[0m'), str_length - 5)
 def test_title_line_breaks(self):
     """Test that the result begins and ends with a line break"""
     test_str = "test str"
     formatted_str = PrintFormatter.title(test_str)
     str_length = len(formatted_str)
     self.assertTrue(str_length > 2)
     self.assertEqual(formatted_str[0], '\n')
     self.assertEqual(formatted_str[str_length - 1], '\n')
예제 #5
0
 def get_help(self):
     """Return the detailed help about the "help" command options and usage."""
     return (
         PF.title("Help command manual") + PF.section("Description") +
         PF.paragraph(self.description) + PF.section("Synopsis") +
         PF.paragraph(Color.BOLD + "./orchid help [COMMAND]" + Color.END) +
         PF.section("Description") + PF.paragraph(
             "With no " + Color.BOLD + "COMMAND" + Color.END +
             " specified, print available commands on the standard output.")
         + PF.paragraph(
             "If " + Color.BOLD + "COMMAND" + Color.END +
             " is specified and exists, print the help manual of the command on the standard output."
         ))
 def test_title_removes_inner_line_breaks(self):
     """Test that inner line breaks are removed"""
     test_str = "test\nbroken\nstr"
     formatted_str = PrintFormatter.title(test_str)
     str_length = len(formatted_str)
     self.assertEqual(formatted_str, "\n\033[1mTEST BROKEN STR\033[0m\n")
 def test_title_empty_string(self):
     """Test that the result is an empty string for an empty string"""
     test_str = ""
     formatted_str = PrintFormatter.title(test_str)
     self.assertEqual(formatted_str, "")
 def test_title_is_upper(self):
     """Test that the content to format is kept as upper case"""
     test_str = "test str"
     formatted_str = PrintFormatter.title(test_str)
     self.assertEqual(formatted_str.count(test_str.upper()), 1)
 def test_paragraphsub_preserves_capitalization(self):
     """Test that capitalization is preserved"""
     test_str = "tEst brOKen str"
     formatted_str = PrintFormatter.paragraphsub(test_str)
     str_length = len(formatted_str)
     self.assertEqual(formatted_str, "        tEst brOKen str\n")
 def test_paragraphsub_removes_internal_line_breaks(self):
     """Test that inner line breaks are replaced by spaces"""
     test_str = "test\nbroken\nstr"
     formatted_str = PrintFormatter.paragraphsub(test_str)
     str_length = len(formatted_str)
     self.assertEqual(formatted_str, "        test broken str\n")
 def test_paragraphsub_containing_formatting(self):
     """Test that internal formatting marks are preserved"""
     test_str = "test " + Color.BOLD + "bold" + Color.END + " str"
     formatted_str = PrintFormatter.paragraphsub(test_str)
     self.assertEqual(formatted_str,
                      "        test \033[1mbold\033[0m str\n")
 def test_paragraphsub_empty_string(self):
     """Test that the result is an empty string for an empty string"""
     test_str = ""
     formatted_str = PrintFormatter.paragraphsub(test_str)
     self.assertEqual(formatted_str, "")
 def test_paragraphsub_is_indented(self):
     """Test that the result format is properly indented"""
     test_str = "test str"
     formatted_str = PrintFormatter.paragraphsub(test_str)
     str_length = len(formatted_str)
     self.assertEqual(formatted_str, "        test str\n")
 def public_remove_line_breaks(str):
     return PrintFormatter._remove_line_breaks(str)
 def public_remove_format_marks(str):
     return PrintFormatter._remove_format_marks(str)