code: def test_no_may_keep_one(eager):
      """Test object caching.
  
      - After init, no objects are cached (as max cached is 0), except when eager caching
      - After increasing max to 2, up to 2 objects are cached
      - Decreasing max objects will evict them on flush
      """
      cache = _ObjectCache(may_keep_one=eager)
  
      # max(A) = 0, so we we only cache when eager caching
      assert cache.cache_object("A", 1) == eager
      assert cache.num_cached_objects == int(eager)
  
      # Set max(A) = 2
      cache.increase_max("A", 2)
  
      # max(A) = 2, so we cache up to two objects
      if not eager:
          assert cache.cache_object("A", 1)
  
      assert cache.cache_object("A", 2)
      assert not cache.cache_object("A", 3)
  
      assert cache.num_cached_objects == 2
  
      # Nothing has to be evicted
      assert not list(cache.flush_cached_objects())
  
      # Set max(A) = 1, so we have one object too much
      cache.decrease_max("A", 1)
  
      # First cached object is evicted
      assert list(cache.flush_cached_objects()) == [1]
      assert cache.num_cached_objects == 1
  
      # Set max(A) = 0
      cache.decrease_max("A", 1)
  
      # Second cached object is evicted if not eager caching
      assert list(cache.flush_cached_objects()) == (
          [2] if not eager else []
      )
      assert cache.num_cached_objects == (0 if not eager else 1)
  
imports: import pytest
  from ray.tune.utils.object_cache import _ObjectCache
label_desc: Use image node_id 1 for calling a global function with example usage: test_no_may_keep_one(eager) without return types