예제 #1
0
 def test_basic(self):
     """move_files: move files to destdir"""
     files = self.makefiles("src/file1", "src/subdir/file2")
     move_files(files, self.destdir, self.srcdir)
     self.assertEqual(set(listfiles(self.destdir)),
                      set(["file1", "subdir/file2"]))
     self.assertEqual(list(iter_files(self.srcdir)), [])
예제 #2
0
 def test_overwrite(self):
     """move_files: overwrite files with the same name"""
     src, dest = self.makefiles("src/file1", "dest/file1")
     with open(src, 'w') as outf:
         outf.write("srcfile")
     with open(dest, 'w') as outf:
         outf.write("destfile")
     move_files([src], self.destdir)
     self.assertEqual(os.listdir(self.destdir), ["file1"])
     self.assertEqual(open(dest).read(), "srcfile")
     self.assertEqual(list(iter_files(self.srcdir)), [])
예제 #3
0
 def test_overwrite(self):
     """move_files: overwrite files with the same name"""
     src, dest = self.makefiles("src/file1", "dest/file1")
     with open(src, 'w') as outf:
         outf.write("srcfile")
     with open(dest, 'w') as outf:
         outf.write("destfile")
     move_files([src], self.destdir, self.srcdir)
     self.assertEqual(list(listfiles(self.destdir)), ["file1"])
     self.assertEqual(open(dest).read(), "srcfile")
     self.assertEqual(list(iter_files(self.srcdir)), [])
예제 #4
0
 def test_pattern(self):
     """iter_files: match filename against glob pattern"""
     self.makefiles("src/file1.so", "src/sub.ko/file2")
     goodfiles = set(self.makefiles("src/sub/file1.ko", "src/file2.ko.xz"))
     result = set(iter_files(self.tmpdir, pattern="*.ko*"))
     self.assertEqual(result, goodfiles)
예제 #5
0
 def test_basic(self):
     """iter_files: iterates over full paths to files under topdir"""
     files = set(self.makefiles("src/file1", "dest/file2", "src/sub/file3"))
     makedir(self.tmpdir+'/empty/dir')
     result = set(iter_files(self.tmpdir))
     self.assertEqual(files, result)
예제 #6
0
 def test_copy_to_parent(self):
     """copy_file: skip files in subdirs of destdir"""
     files = self.makefiles("dest/subdir/file1")
     copy_files(files, self.destdir)
     self.assertEqual(list(iter_files(self.destdir)), files)
예제 #7
0
 def test_move_to_parent(self):
     """move_files: leave files alone if they're in a subdir of destdir"""
     files = set(self.makefiles("dest/subdir/file1", "dest/file2"))
     move_files(files, self.destdir)
     self.assertEqual(set(iter_files(self.destdir)), files)
예제 #8
0
 def test_basic(self):
     """move_files: move files to destdir"""
     files = self.makefiles("src/file1", "src/subdir/file2")
     move_files(files, self.destdir)
     self.assertEqual(set(os.listdir(self.destdir)), set(["file1", "file2"]))
     self.assertEqual(list(iter_files(self.srcdir)), [])
예제 #9
0
 def test_move_to_parent(self):
     """move_files: leave files alone if they're in a subdir of destdir"""
     files = set(self.makefiles("dest/subdir/file1", "dest/file2"))
     move_files(files, self.destdir, self.srcdir)
     self.assertEqual(set(iter_files(self.destdir)), files)
예제 #10
0
 def test_pattern(self):
     """iter_files: match filename against glob pattern"""
     self.makefiles("src/file1.so", "src/sub.ko/file2")
     goodfiles = set(self.makefiles("src/sub/file1.ko", "src/file2.ko.xz"))
     result = set(iter_files(self.tmpdir, pattern="*.ko*"))
     self.assertEqual(result, goodfiles)
예제 #11
0
 def test_basic(self):
     """iter_files: iterates over full paths to files under topdir"""
     files = set(self.makefiles("src/file1", "dest/file2", "src/sub/file3"))
     makedir(self.tmpdir + '/empty/dir')
     result = set(iter_files(self.tmpdir))
     self.assertEqual(files, result)
예제 #12
0
 def test_copy_to_parent(self):
     """copy_file: skip files in subdirs of destdir"""
     files = self.makefiles("dest/subdir/file1")
     copy_files(files, self.destdir, "src")
     self.assertEqual(list(iter_files(self.destdir)), files)
예제 #13
0
 def test_basic(self):
     """move_files: move files to destdir"""
     files = self.makefiles("src/file1", "src/subdir/file2")
     move_files(files, self.destdir, self.srcdir)
     assert set(listfiles(self.destdir)) == set(["file1", "subdir/file2"])
     assert list(iter_files(self.srcdir)) == []