Пример #1
0
 def test_upload_with_plugins(self):
     flags = flags_parser.parse_flags(
         ["uploader", "upload", "--plugins", "plugin1,plugin2"])
     self.assertEqual(
         flags_parser.SUBCOMMAND_KEY_UPLOAD,
         getattr(flags, flags_parser.SUBCOMMAND_FLAG),
     )
     self.assertEqual(["plugin1", "plugin2"], flags.plugins)
Пример #2
0
 def test_upload_logdir(self):
     flags = flags_parser.parse_flags(
         ["uploader", "upload", "--logdir", "some/log/dir"])
     self.assertEqual(
         flags_parser.SUBCOMMAND_KEY_UPLOAD,
         getattr(flags, flags_parser.SUBCOMMAND_FLAG),
     )
     self.assertEqual("some/log/dir", flags.logdir)
Пример #3
0
def _parse_flags(argv=("", )):
    """Integration point for `absl.app`.

    Exits if flag values are invalid.

    Args:
      argv: CLI arguments, as with `sys.argv`, where the first argument is taken
        to be the name of the program being executed.

    Returns:
      Either argv[:1] if argv was non-empty, or [''] otherwise, as a mechanism
      for absl.app.run() compatibility.
    """
    arg0 = argv[0] if argv else ""
    global _FLAGS
    _FLAGS = flags_parser.parse_flags(argv)
    return [arg0]
Пример #4
0
 def test_list(self):
     flags = flags_parser.parse_flags(["uploader", "list"])
     self.assertEqual(
         flags_parser.SUBCOMMAND_KEY_LIST,
         getattr(flags, flags_parser.SUBCOMMAND_FLAG),
     )
Пример #5
0
 def test_unknown_command(self):
     with self.assertRaises(SystemExit):
         flags_parser.parse_flags(["uploader", "unknown"])