Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)