Beispiel #1
0
class TestSBToolsOptionParserMethods(unittest.TestCase):
    """
    Unit tests for the SBToolsOptionParser class.
    """
    def setUp(self):
        self.sbtools = SBTools()
        self.parser = self.sbtools.parser

    def test001_init(self):
        self.assertEqual(self.parser.sbtools, self.sbtools)

    def test002_get_help(self):
        helpstr = self.parser.get_help()
        exptstr = """Usage: sbtools <subcommand> [options] [args]

Type 'sbtools help <subcommand>' for help on a specific subcommand.
Type 'sbtools --version' to see the program version.
Type 'sbtools --verbose-load' to see the packages and plug-ins detected, and
if plug-ins are successfully loaded.

Subcommands consist of built-in subcommands and subcommands provided by
installed plug-ins.

Available subcommands:
%s""" % (self.sbtools.get_subcommands())
        self.assertEqual(helpstr, exptstr)

    def test003_get_unknown_argument_error(self):
        errmsg = self.parser.get_unknown_argument_error('unknown-sc')
        self.assertEqual(errmsg, "Unknown command: 'unknown-sc'.\nType 'sbtools help' for usage information.")

    def test004_get_usage_command(self):
        usagecomm = self.parser.get_usage_command()
        self.assertEqual(usagecomm, "Type 'sbtools help' for usage information.")