Пример #1
0
 def test_basic(self):
     """copy_file: copy files into destdir, leaving existing contents"""
     files = self.makefiles("src/file1", "src/subdir/file2")
     self.makefiles("dest/file3")
     copy_files(files, self.destdir)
     result = set(os.listdir(self.destdir))
     self.assertEqual(result, set(["file1", "file2", "file3"]))
Пример #2
0
 def test_basic(self):
     """copy_file: copy files into destdir, leaving existing contents"""
     files = self.makefiles("src/file1", "src/subdir/file2")
     self.makefiles("dest/file3")
     copy_files(files, self.destdir, self.srcdir)
     result = set(listfiles(self.destdir))
     self.assertEqual(result, set(["file1", "subdir/file2", "file3"]))
Пример #3
0
 def test_copy_kernel(self):
     """copy_file: strip leading module directories"""
     files = self.makefiles("src/lib/modules/3.2.1-900.fc47.x86_64/kernel/subdir/module.ko",
                            "src/lib/modules/3.2.1-900.fc47.x86_64/kernel/other.ko.xz")
     copy_files(files, self.destdir, self.srcdir+"/lib/modules")
     result = set(listfiles(self.destdir))
     self.assertEqual(result, set(["subdir/module.ko", "other.ko.xz"]))
Пример #4
0
 def test_samefile(self):
     """copy_file: skip files already in destdir"""
     (dest,) = self.makefiles("dest/file1")
     with open(dest, 'w') as outf:
         outf.write("destfile")
     copy_files([dest], self.destdir)
     self.assertEqual(os.listdir(self.destdir), ["file1"])
     self.assertEqual(open(dest).read(), "destfile")
Пример #5
0
 def test_samefile(self):
     """copy_file: skip files already in destdir"""
     (dest, ) = self.makefiles("dest/file1")
     with open(dest, 'w') as outf:
         outf.write("destfile")
     copy_files([dest], self.destdir, "src")
     self.assertEqual(list(listfiles(self.destdir)), ["file1"])
     self.assertEqual(open(dest).read(), "destfile")
Пример #6
0
 def test_overwrite(self):
     """copy_file: overwrite files in destdir if they have 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")
     copy_files([src], self.destdir)
     self.assertEqual(os.listdir(self.destdir), ["file1"])
     self.assertEqual(open(dest).read(), "srcfile")
Пример #7
0
 def test_overwrite(self):
     """copy_file: overwrite files in destdir if they have 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")
     copy_files([src], self.destdir, self.srcdir)
     self.assertEqual(list(listfiles(self.destdir)), ["file1"])
     self.assertEqual(open(dest).read(), "srcfile")
Пример #8
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)
Пример #9
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)