code: def test_lightgbm_pruning_callback_errors(cv: bool) -> None:
      # Unknown metric.
      study = optuna.create_study(pruner=DeterministicPruner(False))
      with pytest.raises(ValueError):
          study.optimize(
              lambda trial: objective(
                  trial, metric="foo_metric", cv=cv
              ),
              n_trials=1,
              catch=(),
          )
  
      if not cv:
          # Unknown validation name.
          study = optuna.create_study(pruner=DeterministicPruner(False))
          with pytest.raises(ValueError):
              study.optimize(
                  lambda trial: objective(
                      trial,
                      valid_name="valid_1",
                      force_default_valid_names=True,
                  ),
                  n_trials=1,
                  catch=(),
              )
  
      # Check consistency of study direction.
      study = optuna.create_study(pruner=DeterministicPruner(False))
      with pytest.raises(ValueError):
          study.optimize(
              lambda trial: objective(trial, metric="auc", cv=cv),
              n_trials=1,
              catch=(),
          )
  
      study = optuna.create_study(
          pruner=DeterministicPruner(False), direction="maximize"
      )
      with pytest.raises(ValueError):
          study.optimize(
              lambda trial: objective(
                  trial, metric="binary_error", cv=cv
              ),
              n_trials=1,
              catch=(),
          )
  
file_path: optuna/tests/integration_tests/test_lightgbm.py
imports: from functools import partial
  from unittest.mock import patch
  import numpy
  import pytest
  import optuna
  from optuna._imports import try_import
  from optuna.integration.lightgbm import LightGBMPruningCallback
  from optuna.testing.pruners import DeterministicPruner
label_desc: Use image node_id 4 for calling a global function with example usage: test_lightgbm_pruning_callback_errors(cv) without return types