def test_help_command(self):
     oc = OutputCapture()
     oc.capture_output()
     tool = BlinkTool('path')
     tool.main(['tool', 'help'])
     out, err, logs = oc.restore_output()
     self.assertTrue(out.startswith('Usage: '))
     self.assertEqual('', err)
     self.assertEqual('', logs)
 def test_help_argument(self):
     oc = OutputCapture()
     oc.capture_output()
     tool = BlinkTool('path')
     try:
         tool.main(['tool', '--help'])
     except SystemExit:
         pass  # optparse calls sys.exit after showing help.
     finally:
         out, err, logs = oc.restore_output()
     self.assertTrue(out.startswith('Usage: '))
     self.assertEqual('', err)
     self.assertEqual('', logs)
Exemplo n.º 3
0
def main():
    # This is a hack to let us enable DEBUG logging as early as possible.
    # Note this can't be ternary as versioning.check_version()
    # hasn't run yet and this python might be older than 2.5.
    if set(["-v", "--verbose"]).intersection(set(sys.argv)):
        logging_level = logging.DEBUG
    else:
        logging_level = logging.INFO
    configure_logging(logging_level=logging_level)
    BlinkTool(os.path.abspath(__file__)).main()
 def test_command_by_name(self):
     tool = BlinkTool('path')
     self.assertEqual(tool.command_by_name('help').name, 'help')
     self.assertIsNone(tool.command_by_name('non-existent'))
 def test_split_args_with_no_options(self):
     self.assertEqual(
         BlinkTool._split_command_name_from_args(['command', 'arg']),
         ('command', ['arg']))
 def test_split_args_empty(self):
     self.assertEqual(
         BlinkTool._split_command_name_from_args([]), (None, []))
 def test_split_args_basic(self):
     self.assertEqual(
         BlinkTool._split_command_name_from_args(
             ['--global-option', 'command', '--option', 'arg']),
         ('command', ['--global-option', '--option', 'arg']))