(self, filename1, filename2)
| 55 | |
| 56 | # Tests that copy, move, etc one file to another. |
| 57 | def _do_copyish(self, filename1, filename2): |
| 58 | # Should be able to rename the file using either name. |
| 59 | self.assertTrue(os.path.isfile(filename1)) # must exist. |
| 60 | os.rename(filename1, filename2 + ".new") |
| 61 | self.assertFalse(os.path.isfile(filename2)) |
| 62 | self.assertTrue(os.path.isfile(filename1 + '.new')) |
| 63 | os.rename(filename1 + ".new", filename2) |
| 64 | self.assertFalse(os.path.isfile(filename1 + '.new')) |
| 65 | self.assertTrue(os.path.isfile(filename2)) |
| 66 | |
| 67 | shutil.copy(filename1, filename2 + ".new") |
| 68 | os.unlink(filename1 + ".new") # remove using equiv name. |
| 69 | # And a couple of moves, one using each name. |
| 70 | shutil.move(filename1, filename2 + ".new") |
| 71 | self.assertFalse(os.path.exists(filename2)) |
| 72 | self.assertTrue(os.path.exists(filename1 + '.new')) |
| 73 | shutil.move(filename1 + ".new", filename2) |
| 74 | self.assertFalse(os.path.exists(filename2 + '.new')) |
| 75 | self.assertTrue(os.path.exists(filename1)) |
| 76 | # Note - due to the implementation of shutil.move, |
| 77 | # it tries a rename first. This only fails on Windows when on |
| 78 | # different file systems - and this test can't ensure that. |
| 79 | # So we test the shutil.copy2 function, which is the thing most |
| 80 | # likely to fail. |
| 81 | shutil.copy2(filename1, filename2 + ".new") |
| 82 | self.assertTrue(os.path.isfile(filename1 + '.new')) |
| 83 | os.unlink(filename1 + ".new") |
| 84 | self.assertFalse(os.path.exists(filename2 + '.new')) |
| 85 | |
| 86 | def _do_directory(self, make_name, chdir_name): |
| 87 | if os.path.isdir(make_name): |
no test coverage detected