code: def test_indirectory(tmpdir):
      tmpdir.chdir()
  
      os.makedirs("subdir1/subdir2")
      sd1 = os.path.abspath("subdir1")
      sd2 = os.path.abspath("subdir1/subdir2")
  
      assert os.getcwd() == tmpdir.strpath
      with indirectory("/"):
          assert os.getcwd() == "/"
      assert os.getcwd() == tmpdir.strpath
      with indirectory("subdir1"):
          assert os.getcwd() == sd1
          with indirectory("subdir2"):
              assert os.getcwd() == sd2
              with indirectory(".."):
                  assert os.getcwd() == sd1
                  with indirectory("/"):
                      assert os.getcwd() == "/"
                  assert os.getcwd() == sd1
              assert os.getcwd() == sd2
          assert os.getcwd() == sd1
      assert os.getcwd() == tmpdir.strpath
      try:
          with indirectory("subdir1"):
              raise ValueError("Erroring out of context")
      except ValueError:
          pass
      assert os.getcwd() == tmpdir.strpath
  
imports: import os
  import time
  from pathlib import Path
  from unittest import mock, SkipTest
  import pytest
  from ...testing import TempFATFS
  from ...utils.filemanip import save_json, load_json, fname_presuffix, fnames_presuffix, hash_rename, check_forhash, _parse_mount_table, _cifs_table, on_cifs, copyfile, copyfiles, ensure_list, simplify_list, check_depends, split_filename, get_related_files, indirectory, loadpkl, loadcrash, savepkl, path_resolve, write_rst_list, emptydirs
label_desc: Use image node_id 24 for calling a global function with example usage: test_indirectory(tmpdir) without return types