code: def test_tar_path(tmpdir: Path, monkeypatch):
      source_dir, inner_dir = _create_files(tmpdir)
  
      # Test directory
      target_file = tmpdir / "target.tar.gz"
      results = _tar_path(
          source_path=source_dir, target_file=target_file
      )
      assert results.before_size > 0
      assert results.after_size > 0
  
      verify_dir = tmpdir / "verify"
      os.makedirs(verify_dir)
      with tarfile.open(target_file) as tar:
          tar.extractall(verify_dir)
  
      assert (verify_dir / "f1").exists()
      assert (verify_dir / "dir" / "f2").exists()
  
      # Test single file
      f2_path = inner_dir / "f2"
  
      target_file = tmpdir / "target_file.tar.gz"
      results = _tar_path(source_path=f2_path, target_file=target_file)
      assert results.before_size > 0
      assert results.after_size > 0
  
      verify_dir = tmpdir / "verify_file"
      os.makedirs(verify_dir)
      with tarfile.open(target_file) as tar:
          tar.extractall(verify_dir)
  
      assert (verify_dir / "f2").exists()
  
      # Test single file (local)
      monkeypatch.chdir(inner_dir)
  
      f2_path = "f2"
  
      target_file = tmpdir / "target_file_local.tar.gz"
      results = _tar_path(source_path=f2_path, target_file=target_file)
      assert results.before_size > 0
      assert results.after_size > 0
  
      verify_dir = tmpdir / "verify_file_local"
      os.makedirs(verify_dir)
      with tarfile.open(target_file) as tar:
          tar.extractall(verify_dir)
  
      assert (verify_dir / "f2").exists()
  
file_path: pytorch-lightning/tests/tests_app/source_code/test_tar.py
imports: import math
  import os
  import tarfile
  from pathlib import Path
  import pytest
  from lightning.app.source_code.tar import MAX_SPLIT_COUNT, _get_dir_size_and_count, _get_split_size, _tar_path
label_desc: Use image node_id 5 for calling a global function with example usage: test_tar_path(tmpdir, monkeypatch) without return types