def test_add_command(self): """CommandParser.add_command works for a single command using argparse """ p = CommandParser(subparser=ArgumentParser) cmd = p.add_command('slow') self.assertTrue(isinstance(cmd, ArgumentParser)) self.assertEqual(p.list_commands(), ['slow'])
def test_add_command(self): """CommandParser.add_command works for a single command using optparse """ # Skip the test if optparse not available if not OPTPARSE_AVAILABLE: raise unittest.SkipTest("'optparse' not available") p = CommandParser(subparser=OptionParser) cmd = p.add_command('slow') self.assertTrue(isinstance(cmd, OptionParser)) self.assertEqual(p.list_commands(), ['slow'])
def test_add_multiple_commands(self): """CommandParser.add_command works for multiple commands using argparse """ p = CommandParser(subparser=ArgumentParser) slow_cmd = p.add_command('slow') fast_cmd = p.add_command('fast') medium_cmd = p.add_command('medium') self.assertTrue(isinstance(slow_cmd, ArgumentParser)) self.assertTrue(isinstance(fast_cmd, ArgumentParser)) self.assertTrue(isinstance(medium_cmd, ArgumentParser)) self.assertEqual(p.list_commands(), ['slow', 'fast', 'medium'])
def test_add_multiple_commands(self): """CommandParser.add_command works for multiple commands using optparse """ # Skip the test if optparse not available if not OPTPARSE_AVAILABLE: raise unittest.SkipTest("'optparse' not available") p = CommandParser(subparser=OptionParser) slow_cmd = p.add_command('slow') fast_cmd = p.add_command('fast') medium_cmd = p.add_command('medium') self.assertTrue(isinstance(slow_cmd, OptionParser)) self.assertTrue(isinstance(fast_cmd, OptionParser)) self.assertTrue(isinstance(medium_cmd, OptionParser)) self.assertEqual(p.list_commands(), ['slow', 'fast', 'medium'])