code: def test_predict_method(predict_method):
      class Dummy(BaseEstimator, ClassifierMixin):
          def fit(self, X, y):
              return self
  
          def predict(self, X):
              raise Exception("predict")
  
          def predict_proba(self, X):
              raise Exception("predict_proba")
  
          def decision_function(self, X):
              raise Exception("decision_function")
  
      X, y = make_classification()
      sensitive_feature = np.random.randint(0, 2, len(y))
      clf = ThresholdOptimizer(
          estimator=Dummy(), predict_method=predict_method
      )
      exception = (
          "predict_proba"
          if predict_method == "auto"
          else predict_method
      )
      with pytest.raises(Exception, match=exception):
          clf.fit(X, y, sensitive_features=sensitive_feature)
  
imports: from copy import deepcopy
  from test.unit.input_convertors import _map_into_single_column
  import numpy
  import pandas
  import pytest
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.datasets import make_classification
  from fairlearn.postprocessing import ThresholdOptimizer
  from fairlearn.postprocessing._threshold_optimizer import BASE_ESTIMATOR_NONE_ERROR_MESSAGE, NOT_SUPPORTED_CONSTRAINTS_ERROR_MESSAGE
  from fairlearn.postprocessing._tradeoff_curve_utilities import DEGENERATE_LABELS_ERROR_MESSAGE
  from fairlearn.utils._input_validation import _LABELS_NOT_0_1_ERROR_MESSAGE, _MESSAGE_SENSITIVE_FEATURES_NONE, _MESSAGE_Y_NONE
  from .conftest import ExamplePredictor, X_ex, _get_predictions_by_sensitive_feature, candidate_A_transforms, candidate_X_transforms, candidate_Y_transforms, degenerate_labels_ex, is_invalid_transformation, labels_ex, scores_ex, sensitive_feature_names_ex1, sensitive_features_ex1
label_desc: Use image node_id 15 for calling a global function with example usage: test_predict_method(predict_method) and returns: self