def test_create_common_parser_passed_usage_string(self, mock_func): mock_parser = Mock() mock_parser.parse_args.return_value = lambda: Mock(), [] mock_func.return_value = mock_parser storagestats_parse_args(args=[]) kwargs = mock_func.call_args_list[0][1] expected_usage_suffix = '[options]' self.assertTrue(kwargs['usage'].endswith(expected_usage_suffix))
def storagestats_handle_args(): parser, options, args = storagestats_parse_args() try: storagestats_validate_options_and_args(options, args) except Exception, e: stdout.write(str(e) + '\n') parser.print_help() raise e
def validate(): parser, options, args = storagestats_parse_args(args=[ '--config', self.config_path, 'some_argument']) storagestats_validate_options_and_args(options, args)
def test_create_common_parser_used(self, mock_func): mock_parser = Mock() mock_parser.parse_args.return_value = lambda: Mock(), [] mock_func.return_value = mock_parser storagestats_parse_args(args=[]) self.assertTrue(mock_func.called)