docstr: Test with local paths
          
docstr_tok: ["Test","with","local","paths"]
code: def test_get_full_path_local(self, tmpdir):
      """Test with local paths"""
      # Create a few files
      num_files = 10
  
      audio_files_relative_path = [
          f"file_{n}.test" for n in range(num_files)
      ]
      audio_files_absolute_path = [
          os.path.join(tmpdir, a_file_rel)
          for a_file_rel in audio_files_relative_path
      ]
  
      data_dir = tmpdir
      manifest_file = os.path.join(data_dir, "manifest.json")
  
      # Context manager to create dummy files
      @contextmanager
      def create_files(paths):
          # Create files
          for a_file in paths:
              Path(a_file).touch()
          yield
          # Remove files
          for a_file in paths:
              Path(a_file).unlink()
  
      # 1) Test with absolute paths and while files don't exist.
      # Note: it's still expected the path will be resolved correctly, since it will be
      # expanded using manifest_file.parent or data_dir and relative path.
      # - single file
      for n in range(num_files):
          assert (
              get_full_path(
                  audio_files_absolute_path[n],
                  manifest_file=manifest_file,
              )
              == audio_files_absolute_path[n]
          )
          assert (
              get_full_path(
                  audio_files_absolute_path[n], data_dir=data_dir
              )
              == audio_files_absolute_path[n]
          )
  
      # - all files in a list
      assert (
          get_full_path(
              audio_files_absolute_path, manifest_file=manifest_file
          )
          == audio_files_absolute_path
      )
      assert (
          get_full_path(audio_files_absolute_path, data_dir=data_dir)
          == audio_files_absolute_path
      )
  
      # 2) Test with absolute paths and existing files.
      with create_files(audio_files_absolute_path):
          # - single file
          for n in range(num_files):
              assert (
                  get_full_path(
                      audio_files_absolute_path[n],
                      manifest_file=manifest_file,
                  )
                  == audio_files_absolute_path[n]
              )
              assert (
                  get_full_path(
                      audio_files_absolute_path[n], data_dir=data_dir
                  )
                  == audio_files_absolute_path[n]
              )
  
          # - all files in a list
          assert (
              get_full_path(
                  audio_files_absolute_path, manifest_file=manifest_file
              )
              == audio_files_absolute_path
          )
          assert (
              get_full_path(
                  audio_files_absolute_path, data_dir=data_dir
              )
              == audio_files_absolute_path
          )
  
      # 3) Test with relative paths while files don't exist.
      # This is a situation we may have with a tarred dataset.
      # In this case, we expect to return the relative path.
      # - single file
      for n in range(num_files):
          assert (
              get_full_path(
                  audio_files_relative_path[n],
                  manifest_file=manifest_file,
              )
              == audio_files_relative_path[n]
          )
          assert (
              get_full_path(
                  audio_files_relative_path[n], data_dir=data_dir
              )
              == audio_files_relative_path[n]
          )
  
      # - all files in a list
      assert (
          get_full_path(
              audio_files_relative_path, manifest_file=manifest_file
          )
          == audio_files_relative_path
      )
      assert (
          get_full_path(audio_files_relative_path, data_dir=data_dir)
          == audio_files_relative_path
      )
  
      # 4) Test with relative paths and existing files.
      # In this case, we expect to return the absolute path.
      with create_files(audio_files_absolute_path):
          # - single file
          for n in range(num_files):
              assert (
                  get_full_path(
                      audio_files_relative_path[n],
                      manifest_file=manifest_file,
                  )
                  == audio_files_absolute_path[n]
              )
              assert (
                  get_full_path(
                      audio_files_relative_path[n], data_dir=data_dir
                  )
                  == audio_files_absolute_path[n]
              )
  
          # - all files in a list
          assert (
              get_full_path(
                  audio_files_relative_path, manifest_file=manifest_file
              )
              == audio_files_absolute_path
          )
          assert (
              get_full_path(
                  audio_files_relative_path, data_dir=data_dir
              )
              == audio_files_absolute_path
          )
  
      # 5) Test with relative paths and existing files, and the filepaths start with './'.
      # In this case, we expect to return the same relative path.
      curr_dir = os.path.dirname(os.path.abspath(__file__))
      audio_files_relative_path_curr = [
          f"./file_{n}.test" for n in range(num_files)
      ]
      with create_files(audio_files_relative_path_curr):
          # - single file
          for n in range(num_files):
              assert (
                  os.path.isfile(audio_files_relative_path_curr[n])
                  == True
              )
              assert (
                  get_full_path(
                      audio_files_relative_path_curr[n],
                      manifest_file=manifest_file,
                  )
                  == audio_files_relative_path_curr[n]
              )
              assert (
                  get_full_path(
                      audio_files_relative_path_curr[n],
                      data_dir=curr_dir,
                  )
                  == audio_files_relative_path_curr[n]
              )
  
          # - all files in a list
          assert (
              get_full_path(
                  audio_files_relative_path_curr,
                  manifest_file=manifest_file,
              )
              == audio_files_relative_path_curr
          )
          assert (
              get_full_path(
                  audio_files_relative_path_curr, data_dir=curr_dir
              )
              == audio_files_relative_path_curr
          )
  
file_path: NeMo/tests/collections/common/test_utils.py
imports: import os
  import string
  from contextlib import contextmanager
  from pathlib import Path
  from unittest import mock
  import numpy
  import pytest
  from nemo.collections.common.parts.preprocessing.manifest import get_full_path, is_tarred_dataset
  from nemo.collections.common.parts.utils import flatten
label_desc: Use image node_id 1 for calling the TestPreprocessingUtils obj's underlying member method code with example usage: obj.test_get_full_path_local(tmpdir) without return types