Example #1
0
 def test_mk_options(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_options(),
                      ".SH OPTIONS\n"
                      "  arg1\n\n"
                      "  -h, --help  show this help message and exit\n"
                      "  -a A\n")
Example #2
0
    def test_formatter(self):
        parser = test_arg_parser(ManPageFormatter)
        self.assertEqual(
            parser.format_help(),
            "usage: {0} [-h] [-a A] arg1\n\n{1}\n\n"
            "positional arguments:\n"
            "  arg1\n\n"
            "optional arguments:\n"
            "  \\fB-h\\fR, \\fB--help\\fR\n"
            "                        show this help message and exit\n"
            "  \\fB-a\\fR \\fIA\\fR\n"
            .format(app_name, app_description))

        parser = ManPageFormatter(app_name,
                                  parser=argparse.ArgumentParser(prog=app_name))
        today = datetime.date.today().strftime('%Y\\-%m\\-%d')
        self.assertEqual(parser.format_man_page(),
                         ".TH {0} 1 {1}\n"
                         ".SH NAME\n"
                         "{0}\n"
                         ".SH SYNOPSIS\n"
                         " \\fBname\\fR [-h]\n\n\n"
                         ".SH OPTIONS\n"
                         "  -h, --help  show this help message and exit\n"
                         .format(app_name, today))
Example #3
0
    def test_formatter(self):
        parser = test_arg_parser(ManPageFormatter)
        self.assertEqual(
            parser.format_help(),
            "usage: {0} [-h] [-a A] arg1\n\n{1}\n\n"
            "positional arguments:\n"
            "  arg1\n\n"
            "optional arguments:\n"
            "  \\fB-h\\fR, \\fB--help\\fR\n"
            "                        show this help message and exit\n"
            "  \\fB-a\\fR \\fIA\\fR\n"
            .format(app_name, app_description))

        parser = ManPageFormatter(app_name,
                                  parser=argparse.ArgumentParser(
                                      prog=app_name))
        today = datetime.date.today().strftime('%Y\\-%m\\-%d')
        self.assertEqual(parser.format_man_page(),
                         ".TH {0} 1 {1}\n"
                         ".SH NAME\n"
                         "{0}\n"
                         ".SH SYNOPSIS\n"
                         " \\fBname\\fR [-h]\n\n\n"
                         ".SH OPTIONS\n"
                         "  -h, --help  show this help message and exit\n"
                         .format(app_name, today))
Example #4
0
 def test_format_functions(self):
     uut = ManPageFormatter(app_name)
     self.assertEqual(ManPageFormatter._markup("a-b"), "a\\-b")
     self.assertEqual(ManPageFormatter._underline("test"), "\\fItest\\fR")
     self.assertEqual(ManPageFormatter._bold("test"), "\\fBtest\\fR")
     self.assertEqual(ManPageFormatter._bold("\\fBtest"), "\\fBtest\\fR")
     self.assertEqual(ManPageFormatter._bold("test\\fR"), "\\fBtest\\fR")
Example #5
0
 def test_mk_footer(self):
     uut = ManPageFormatter(app_name, ext_sections=sections)
     self.assertEqual(uut._mk_footer(),
                      ".SH {0}\n"
                      " {1}".format(section_name.upper(), section_text))
     uut = ManPageFormatter(app_name, ext_sections=None)
     self.assertEqual(uut._mk_footer(), "")
Example #6
0
 def test_mk_options(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_options(),
                      ".SH OPTIONS\n"
                      "  arg1\n\n"
                      "  -h, --help  show this help message and exit\n"
                      "  -a A\n")
Example #7
0
 def test_mk_description(self):
     uut = ManPageFormatter(app_name,
                            parser=test_arg_parser())
     self.assertEqual(uut._mk_description(), "")
     uut = ManPageFormatter(app_name,
                            parser=test_arg_parser(),
                            long_desc=app_long_description)
     self.assertEqual(uut._mk_description(),
         ".SH DESCRIPTION\n{}\n".format(app_long_description))
Example #8
0
 def test_format_functions(self):
     uut = ManPageFormatter(app_name)
     self.assertEqual(ManPageFormatter._markup("a-b"), "a\\-b")
     self.assertEqual(ManPageFormatter._underline("test"), "\\fItest\\fR")
     self.assertEqual(ManPageFormatter._bold("test"), "\\fBtest\\fR")
     self.assertEqual(ManPageFormatter._bold("\\fBtest"), "\\fBtest\\fR")
     self.assertEqual(ManPageFormatter._bold("test\\fR"), "\\fBtest\\fR")
Example #9
0
 def test_mk_footer(self):
     uut = ManPageFormatter(app_name, ext_sections=sections)
     self.assertEqual(uut._mk_footer(),
                      ".SH {0}\n"
                      " {1}".format(section_name.upper(), section_text))
     uut = ManPageFormatter(app_name, ext_sections=None)
     self.assertEqual(uut._mk_footer(), "")
Example #10
0
 def test_mk_description(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_description(), '')
     uut = ManPageFormatter(app_name,
                            parser=test_arg_parser(),
                            long_desc=app_long_description)
     self.assertEqual(uut._mk_description(),
                      f'.SH DESCRIPTION\n{app_long_description}\n')
Example #11
0
    def test_formatter(self):
        parser = test_arg_parser(ManPageFormatter)
        self.assertEqual(
            parser.format_help(),
            f'usage: {app_name} [-h] [-a A] arg1\n\n{app_description}\n\n'
            'positional arguments:\n'
            '  arg1\n\n'
            'optional arguments:\n'
            '  \\fB-h\\fR, \\fB--help\\fR\n'
            '                        show this help message and exit\n'
            '  \\fB-a\\fR \\fIA\\fR\n')

        parser = ManPageFormatter(
            app_name, parser=argparse.ArgumentParser(prog=app_name))
        today = datetime.date.today().strftime('%Y\\-%m\\-%d')
        self.assertEqual(
            parser.format_man_page(), f'.TH {app_name} 1 {today}\n'
            '.SH NAME\n'
            f'{app_name}\n'
            '.SH SYNOPSIS\n'
            ' \\fBname\\fR [-h]\n\n\n'
            '.SH OPTIONS\n'
            '  -h, --help  show this help message and exit\n')
Example #12
0
 def test_format_functions(self):
     self.assertEqual(ManPageFormatter._markup('a-b'), 'a\\-b')
     self.assertEqual(ManPageFormatter._underline('test'), '\\fItest\\fR')
     self.assertEqual(ManPageFormatter._bold('test'), '\\fBtest\\fR')
     self.assertEqual(ManPageFormatter._bold('\\fBtest'), '\\fBtest\\fR')
     self.assertEqual(ManPageFormatter._bold('test\\fR'), '\\fBtest\\fR')
Example #13
0
 def test_mk_footer(self):
     uut = ManPageFormatter(app_name, ext_sections=sections)
     self.assertEqual(uut._mk_footer(),
                      f'.SH {section_name.upper()}\n {section_text}')
     uut = ManPageFormatter(app_name, ext_sections=None)
     self.assertEqual(uut._mk_footer(), '')
Example #14
0
 def test_mk_synopsis(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(
         uut._mk_synopsis(),
         ".SH SYNOPSIS\n \\fB{}\\fR [-h] [-a A] arg1\n\n\n".format(app_name))
Example #15
0
 def test_mk_name(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_name(),
                      ".SH NAME\n{}\n".format(app_name))
Example #16
0
 def test_mk_title(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     today = datetime.date.today().strftime('%Y\\-%m\\-%d')
     self.assertEqual(uut._mk_title(),
                      '.TH {0} {1} {2}\n'.format(app_name, 1, today))
Example #17
0
 def test_mk_title(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     today = datetime.date.today().strftime('%Y\\-%m\\-%d')
     self.assertEqual(uut._mk_title(),
                      '.TH {0} {1} {2}\n'.format(app_name, 1, today))
Example #18
0
 def test_mk_name(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_name(),
                      ".SH NAME\n{}\n".format(app_name))
Example #19
0
 def test_mk_synopsis(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(
         uut._mk_synopsis(),
         ".SH SYNOPSIS\n \\fB{}\\fR [-h] [-a A] arg1\n\n\n".format(
             app_name))
Example #20
0
 def test_format_functions(self):
     self.assertEqual(ManPageFormatter._markup('a-b'), 'a\\-b')
     self.assertEqual(ManPageFormatter._underline('test'), '\\fItest\\fR')
     self.assertEqual(ManPageFormatter._bold('test'), '\\fBtest\\fR')
     self.assertEqual(ManPageFormatter._bold('\\fBtest'), '\\fBtest\\fR')
     self.assertEqual(ManPageFormatter._bold('test\\fR'), '\\fBtest\\fR')
Example #21
0
 def test_mk_name(self):
     uut = ManPageFormatter(app_name, parser=test_arg_parser())
     self.assertEqual(uut._mk_name(), f'.SH NAME\n{app_name}\n')