code: def test_grpc_client_credentials_are_generated(monkeypatch):
      # Test that credentials are generated when secure is True, but _credentials
      # isn't passed.
      class Stop(Exception):
          def __init__(self, result):
              self.result = result
  
      def mock_gen_credentials():
          raise Stop("ssl_channel_credentials called")
  
      monkeypatch.setattr(
          grpc, "ssl_channel_credentials", mock_gen_credentials
      )
  
      with pytest.raises(Stop) as stop:
          Worker(secure=True)
      assert stop.value.result == "ssl_channel_credentials called"
  
file_path: ray/python/ray/tests/test_grpc_client_credentials.py
imports: import pytest
  import grpc
  from ray.util.client.worker import Worker
label_desc: Use image node_id 2 for calling a global function with example usage: test_grpc_client_credentials_are_generated(monkeypatch) without return types