class TestHelpMethods(unittest.TestCase): """ Unit tests for the Help core plugin. """ def setUp(self): self.sbtools = SBTools() self.help = Help(self.sbtools) def test001_init(self): self.assertEqual(self.help.sbtools, self.sbtools) def test002_init_parser(self): self.assertEqual(self.help.parser.get_usage().strip(), "Usage: help [subcommand]") self.assertEqual(self.help.parser.get_description(), "help (h, ?): Provide usage information on the SBTools core package or a plug-in when a subcommand is provided.") def test003_get_command(self): self.assertEqual(self.help.get_command(), "help") def test004_get_alt_commands(self): self.assertEqual(self.help.get_alt_commands(), ['h', '?']) def test005_get_full_command_str(self): self.assertEqual(self.help.get_full_command_str(), "help (h, ?)") def test006_get_about(self): self.assertEqual(self.help.get_about(), "The Help tool is a core component of the SBTools package.") def test007_run_unknown_subcommand(self): argv_saved = sys.argv sys.argv = ['sbtools', 'help', 'unknown-sc'] # Make sure the expected exception is raised. self.assertRaises(sbtools.UnknownSubcommandError, self.help.run) # Make sure the expected message is included with the # exception. try: self.help.run() except sbtools.UnknownSubcommandError, msg: self.assertEqual(str(msg), "unknown-sc") sys.argv = argv_saved
def setUp(self): self.sbtools = SBTools() self.help = Help(self.sbtools)