text: # -*- coding: utf-8 -*-
  """Front-end related functions and classes for testing."""
  
  import os
  import unittest
  
  from dfvfs.lib import definitions as dfvfs_definitions
  from dfvfs.path import factory as path_spec_factory
  from dfvfs.resolver import resolver as path_spec_resolver
  # TODO: move the contents of this file to CLI after preg tool refactor.
  
  
  class ToolTestCase(unittest.TestCase):
    """The unit test case for a tool."""
  
    _TEST_DATA_PATH = os.path.join(os.getcwd(), u'test_data')
  
    # Show full diff results, part of TestCase so does not follow our naming
    # conventions.
    maxDiff = None
  
    def _GetTestFileEntryFromPath(self, path_segments):
      """Creates a file entry that references a file in the test dir.
  
      Args:
        path_segments: the path segments inside the test data directory.
  
      Returns:
        A file entry object (instance of dfvfs.FileEntry).
      """
      path = self._GetTestFilePath(path_segments)
      path_spec = path_spec_factory.Factory.NewPathSpec(
          dfvfs_definitions.TYPE_INDICATOR_OS, location=path)
      return path_spec_resolver.Resolver.OpenFileEntry(path_spec)
  
    def _GetTestFilePath(self, path_segments):
      """Retrieves the path of a test file relative to the test data directory.
  
      Args:
        path_segments: the path segments inside the test data directory.
  
      Returns:
        A path of the test file.
      """
      # Note that we need to pass the individual path segments to os.path.join
      # and not a list.
      return os.path.join(self._TEST_DATA_PATH, *path_segments)
  