code: def test_runtime_env(self, mock_sdk_client, runtime_env_formats):
      runner = CliRunner()
      mock_client_instance = mock_sdk_client.return_value
      env_dict, env_json, env_yaml = runtime_env_formats
  
      with set_env_var("RAY_ADDRESS", "env_addr"):
          # Test passing via file.
          result = runner.invoke(
              job_cli_group,
              ["submit", "--runtime-env", env_yaml, "--", "echo hello"],
          )
          check_exit_code(result, 0)
          mock_client_instance.submit_job.assert_called_with(
              entrypoint='"echo hello"',
              submission_id=None,
              runtime_env=env_dict,
              metadata=None,
              entrypoint_num_cpus=None,
              entrypoint_num_gpus=None,
              entrypoint_memory=None,
              entrypoint_resources=None,
          )
  
          # Test passing via json.
          result = runner.invoke(
              job_cli_group,
              [
                  "submit",
                  "--runtime-env-json",
                  env_json,
                  "--",
                  "echo hello",
              ],
          )
          check_exit_code(result, 0)
          mock_client_instance.submit_job.assert_called_with(
              entrypoint='"echo hello"',
              submission_id=None,
              runtime_env=env_dict,
              metadata=None,
              entrypoint_num_cpus=None,
              entrypoint_num_gpus=None,
              entrypoint_memory=None,
              entrypoint_resources=None,
          )
  
          # Test passing both throws an error.
          result = runner.invoke(
              job_cli_group,
              [
                  "submit",
                  "--runtime-env",
                  env_yaml,
                  "--runtime-env-json",
                  env_json,
                  "--",
                  "echo hello",
              ],
          )
          check_exit_code(result, 1)
          assert "Only one of" in str(result.exception)
  
          # Test overriding working_dir.
          env_dict.update(working_dir=".")
          result = runner.invoke(
              job_cli_group,
              [
                  "submit",
                  "--runtime-env",
                  env_yaml,
                  "--working-dir",
                  ".",
                  "--",
                  "echo hello",
              ],
          )
          check_exit_code(result, 0)
          mock_client_instance.submit_job.assert_called_with(
              entrypoint='"echo hello"',
              submission_id=None,
              runtime_env=env_dict,
              metadata=None,
              entrypoint_num_cpus=None,
              entrypoint_num_gpus=None,
              entrypoint_memory=None,
              entrypoint_resources=None,
          )
  
          result = runner.invoke(
              job_cli_group,
              [
                  "submit",
                  "--runtime-env-json",
                  env_json,
                  "--working-dir",
                  ".",
                  "--",
                  "echo hello",
              ],
          )
          check_exit_code(result, 0)
          mock_client_instance.submit_job.assert_called_with(
              entrypoint='"echo hello"',
              submission_id=None,
              runtime_env=env_dict,
              metadata=None,
              entrypoint_num_cpus=None,
              entrypoint_num_gpus=None,
              entrypoint_memory=None,
              entrypoint_resources=None,
          )
  
imports: from contextlib import contextmanager
  import json
  import logging
  from pathlib import Path
  import tempfile
  import os
  from unittest import mock
  import yaml
  from typing import Optional
  from click.testing import CliRunner
  import pytest
  from ray.dashboard.modules.job.cli import job_cli_group
label_desc: Use image node_id 3 for calling the TestSubmit obj's underlying member method code with example usage: obj.test_runtime_env(mock_sdk_client, runtime_env_formats) without return types