class_docstr: Tests for the AlgoWrapper that makes suggest try repeatedly until a new trial is returned.
class_docstr_tok: ["Tests","for","the","AlgoWrapper","that","makes","suggest","try","repeatedly","until","a","new","trial","is","returned","."]
docstr: Test that when the algo can't produce a new trial even after the max number of attempts,
  a warning is logged and an empty list is returned.
docstr_tok: ["Test","that","when","the","algo","ca","n't","produce","a","new","trial","even","after","the","max","number","of","attempts",",","a","warning","is","logged","and","an","empty","list","is","returned","."]
code: def test_warns_when_unable_to_sample_new_trial(
      self,
      algo_wrapper: InsistSuggest[FixedSuggestionAlgo],
      caplog: pytest.LogCaptureFixture,
      monkeypatch: MonkeyPatch,
  ):
      """Test that when the algo can't produce a new trial even after the max number of attempts,
      a warning is logged and an empty list is returned.
      """
  
      calls: int = 0
  
      def _suggest(num: int) -> list[Trial]:
          nonlocal calls
          calls += 1
          if calls < 5:
              return []
          return [
              algo_wrapper.unwrap(FixedSuggestionAlgo).fixed_suggestion
          ]
  
      monkeypatch.setattr(algo_wrapper.algorithm, "suggest", _suggest)
  
      algo_wrapper.max_suggest_attempts = 3
  
      with caplog.at_level(logging.WARNING):
          out = algo_wrapper.suggest(1)
          assert calls == 3
          assert out == []
          assert len(caplog.record_tuples) == 1
          log_record = caplog.record_tuples[0]
          assert log_record[1] == logging.WARNING and log_record[
              2
          ].startswith("Unable to sample a new trial")
  
file_path: orion/tests/unittests/core/worker/algo_wrappers/test_insist_suggest.py
imports: from __future__ import annotations
  import logging
  from typing import ClassVar
  import pytest
  from pytest import MonkeyPatch
  from orion.algo.random import Random
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.worker.algo_wrappers import InsistSuggest
  from orion.core.worker.trial import Trial
  from .base import AlgoWrapperTests
  from .test_transform import FixedSuggestionAlgo
label_desc: Use image node_id 3 for calling the TestInsistSuggestWrapper obj's underlying member method code with example usage: obj.test_warns_when_unable_to_sample_new_trial(algo_wrapper, caplog, monkeypatch) and returns: list, list