def test_move_across_filesystems(self): t = LocalTarget(self.path) with t.open('w') as f: f.write('test_data') def rename_across_filesystems(src, dst): err = OSError() err.errno = EXDEV raise err real_rename = os.rename def mockrename(src, dst): if '-across-fs' in src: real_rename(src, dst) else: rename_across_filesystems(src, dst) copy = '%s-across-fs' % self.copy with mock.patch('os.rename', mockrename): t.move(copy) self.assertFalse(os.path.exists(self.path)) self.assertTrue(os.path.exists(copy)) self.assertEqual('test_data', LocalTarget(copy).open('r').read())
def test_move(self): t = LocalTarget(self.path) f = t.open('w') test_data = 'test' f.write(test_data) f.close() self.assertTrue(os.path.exists(self.path)) self.assertFalse(os.path.exists(self.copy)) t.move(self.copy) self.assertFalse(os.path.exists(self.path)) self.assertTrue(os.path.exists(self.copy))