Пример #1
0
 def test_file_iterator_gets_stats_for_dir_relative_to_base_dir(self):
     dir1full = self._create_dir(self.directory, 'dir1')
     self._create_file(dir1full, 'file1')
     self._create_file(dir1full, 'file2')
     fp = FilePackage()
     fp.add_directory("dir1")
     fp.set_basedir(self.directory)
     self.file_iterator.set_filepackages([fp])
     s = set(self.file_iterator.files())
     eq_(set(self._prepend_dir(['file1', 'file2'], dir1full)), s)
Пример #2
0
    def test_file_package_includes_globbed_directories(self):
        basedir = mkdtemp('-caboose-file-package-tests2')
        dirs = ("1dir", "2dir", "different")
        self.produce_fake_directories(basedir, dirs)

        #create a file package which uses a globbed directory name
        fp = FilePackage()
        fp.set_basedir(basedir)
        fp.add_directory("*dir")

        expected = [os.path.join(basedir, name) for name in ("1dir", "2dir")]
        eq_(set(expected), set(fp.get_directories()))
Пример #3
0
    def test_file_package_add_basedir_subdirs(self):
        basedir = mkdtemp('-caboose-file-package-tests')

        expected_dirs = set(("dir1", "dir2", "dir3"))
        self.produce_fake_directories(basedir, expected_dirs)
        expected_dirs = [os.path.join(basedir, name) for name in expected_dirs]

        #add a file which should be ignored as it is not a directory
        filepath = os.path.join(basedir, "file1")
        with open(filepath, 'w') as f:
            f.write("file contents here")

        fp = FilePackage()
        fp.set_basedir(basedir)
        fp.add_directory("*")

        eq_(set(expected_dirs), set(fp.get_directories()))

        rmtree(basedir)
Пример #4
0
 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()))