def test_match_files_by_filematcher(self):
       self._create_file(self.directory, 'file.txt')
       self._create_file(self.directory, 'file.java')
 
       fm = MockFileMatcher()
       fm.add_match("file.java")
       fp = FilePackage()
       fp.add_directory(self.directory)
       fp.add_file_matcher(fm)
       self.file_iterator.set_filepackages([fp])
 
       s = set(self.file_iterator.files())
       eq_(set([os.path.join(self.directory, 'file.java')]), s)
    def test_match_files_in_directory_tree_by_filematcher(self):
        self._create_file(self.directory, 'file0.java')
        dir1 = self._create_dir(self.directory, 'dir1')
        self._create_file(dir1, 'file1.c')
        dir2 = self._create_dir(dir1, 'dir2')
        self._create_file(dir2, 'file2.java')
        dir3 = self._create_dir(self.directory, 'dir3')
        self._create_file(dir3, 'file3.py')

        fm = MockFileMatcher()
        fm.add_match("file0.java")
        fm.add_match("file2.java")
        fp = FilePackage()
        fp.add_directory(self.directory)
        fp.add_file_matcher(fm)
        self.file_iterator.set_filepackages([fp])
        
        expected = set()
        expected.add(os.path.join(self.directory, 'file0.java'))
        expected.add(os.path.join(dir2, 'file2.java'))
        s = set(self.file_iterator.files())
        eq_(expected, s)
 def test_file_package_holds_file_matchers(self):
     fp = FilePackage()
     fm = MockFileMatcher()
     fp.add_file_matcher(fm)
     eq_(set((fm,)), set(fp.get_file_matchers()))