def test_file_package_excludes_excluded_directories(self): fp = FilePackage() fp.add_directory("dir1") fp.add_directories("dir2", "dir3", "dir4", "dir5") fp.exclude_directory("dir3") fp.exclude_directories("dir4", "dir5") eq_(set(("dir1", "dir2")), set(fp.get_directories()))
def test_iterate_files_in_multiple_directories(self): dir1 = self._create_dir(self.directory, 'dir1') dir2 = self._create_dir(self.directory, 'dir2') self._create_file(dir1, 'file1') self._create_file(dir2, 'file2') fp = FilePackage() fp.add_directories(dir1, dir2) self.file_iterator.set_filepackages([fp]) expected = set() expected.add(os.path.join(dir1, 'file1')) expected.add(os.path.join(dir2, 'file2')) s = set(self.file_iterator.files()) eq_(expected, s)
def test_proper_number_of_lines_in_multiple_dirs(self): directory = mkdtemp("-caboose-numlines-multiple-dir-test") inner1 = mkdtemp("-inner-dir1", dir=directory) inner2 = mkdtemp("-inner-dir2", dir=directory) inner3 = mkdtemp("-inner-dir3", dir=directory) self._create_file_with_lines(directory, 2, 3, 4) self._create_file_with_lines(inner1, 5, 6, 7) self._create_file_with_lines(inner2, 8, 9 ,10) self._create_file_with_lines(inner3, 13, 14, 15) fp = FilePackage() fp.add_directories(inner1, inner3) file_iterator = FileIterator([fp]) stat = StatJavaNcss() stat.set_files(file_iterator.files()) eq_(18, stat.get_stat()) rmtree(directory)
def test_file_package_prepends_basedir(self): fp = FilePackage() fp.set_basedir("/tmp/basedirname") fp.add_directories("dir1", "dir2") expected = set(("/tmp/basedirname/dir1", "/tmp/basedirname/dir2")) eq_(expected, set(fp.get_directories()))
def test_file_package_holds_many_directories(self): fp = FilePackage() fp.add_directory("dir1") fp.add_directories("dir2", "dir3") eq_(set(("dir1", "dir2", "dir3")), set(fp.get_directories()))