```class ProjectTreeTestBase(AbstractClass): @a...
# general
b
Copy code
class ProjectTreeTestBase(AbstractClass):

  @abstractmethod
  def mk_project_tree(self, build_root, ignore_patterns=[]):
    """Construct a ProjectTree for the given build_root path."""
    pass

  def make_base_dir(self):
    """
    :API: public
    """
    return tempfile.mkdtemp()

  def fullpath(self, path):
    """
    :API: public
    """
    return os.path.join(self.root_dir, path)

  def makedirs(self, path):
    """
    :API: public
    """
    safe_mkdir(self.fullpath(path))

  def touch(self, path):
    """
    :API: public
    """
    touch(self.fullpath(path))

  def rmdirs(self, path):
    """
    :API: public
    """
    shutil.rmtree(path)

class PantsIgnoreTestBase(ProjectTreeTestBase):

  def setUp(self):
    """
    :API: public
    """
    self.base_dir = self.make_base_dir()
    self.root_dir = os.path.join(self.base_dir, 'root')

    # make 'root/'
    self.makedirs('')

    # make 'root/...'
    self.touch('apple')
    self.touch('orange')
    self.touch('banana')

    # make 'root/fruit/'
    self.makedirs('fruit')

    # make 'root/fruit/...'
    self.touch('fruit/apple')
    self.touch('fruit/orange')
    self.touch('fruit/banana')

    # make 'root/fruit/fruit/'
    self.makedirs('fruit/fruit')

    # make 'root/fruit/fruit/...'
    self.touch('fruit/fruit/apple')
    self.touch('fruit/fruit/orange')
    self.touch('fruit/fruit/banana')

    self.makedirs('grocery')
    self.touch('grocery/fruit')

    self.cwd = os.getcwd()
    os.chdir(self.root_dir)

  def tearDown(self):
    """
    :API: public
    """
    os.chdir(self.cwd)
    self.rmdirs(self.base_dir)

  def test_ignore_pattern_blank_line(self):
    self._project_tree = self.mk_project_tree(self.root_dir, [""])
    files_list = []
    for root, dirs, files in self._project_tree.walk(''):
      for file in files:
        files_list.append(os.path.join(root, file))
        ……..

class FileSystemPantsIgnoreTest(unittest.TestCase, PantsIgnoreTestBase):

  def mk_project_tree(self, build_root, ignore_patterns=[]):
    return FileSystemProjectTree(build_root, ignore_patterns)