code: def test_custom_cache_dir_with_env_var(
      self, pytester: Pytester, monkeypatch: MonkeyPatch
  ) -> None:
      monkeypatch.setenv("env_var", "custom_cache_dir")
      pytester.makeini(
          """
              [pytest]
              cache_dir = {cache_dir}
          """.format(
              cache_dir="$env_var"
          )
      )
      pytester.makepyfile(
          test_errored="def test_error():\n    assert False"
      )
      pytester.runpytest()
      assert pytester.path.joinpath("custom_cache_dir").is_dir()
  
imports: import os
  import shutil
  from pathlib import Path
  from typing import Generator
  from typing import List
  import pytest
  from _pytest.config import ExitCode
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pytester import Pytester
  from _pytest.tmpdir import TempPathFactory
label_desc: Use image node_id 11 for calling the TestNewAPI obj's underlying member method code with example usage: obj.test_custom_cache_dir_with_env_var(pytester, monkeypatch) without return types