def test_image_with_help(self): parser = argparse.ArgumentParser(add_help=False) # create one subcommand, "snap" subparser = parser.add_subparsers(dest='cmd') subparser.add_parser('snap') argv = get_modified_args(subparser, 'snap', ['--help']) self.assertEqual(['--help'], argv)
def test_image_with_subcommand(self): parser = argparse.ArgumentParser(add_help=False) # create one subcommand, "snap" subparser = parser.add_subparsers(dest='cmd') subparser.add_parser('snap') argv = get_modified_args( subparser, 'snap', ['snap', '-d', '-o', 'pc_amd64.img', 'model.assertion']) self.assertEqual( ['snap', '-d', '-o', 'pc_amd64.img', 'model.assertion'], argv)
def test_image_without_subcommand(self): stderr = StringIO() with patch('sys.stderr', stderr): parser = argparse.ArgumentParser(add_help=False) # create one subcommand, "snap" subparser = parser.add_subparsers(dest='cmd') subparser.add_parser('snap') argv = get_modified_args( subparser, 'snap', ['-o', 'abc.img', '-i', '45', 'model.assertion']) self.assertEqual( ['snap', '-o', 'abc.img', '-i', '45', 'model.assertion'], argv)
def test_image_with_multiple_subcommand(self): stderr = StringIO() with patch('sys.stderr', stderr): parser = argparse.ArgumentParser(add_help=False) # create two subcommands, "snap" and "classic" subparser = parser.add_subparsers(dest='cmd') subparser.add_parser('snap') subparser.add_parser('classic') argv = get_modified_args( subparser, 'classic', ['-d', '-o', 'pc_amd64.img', 'model.assertion']) self.assertEqual( ['classic', '-d', '-o', 'pc_amd64.img', 'model.assertion'], argv)