コード例 #1
0
ファイル: local_target_test.py プロジェクト: spotify/luigi
    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())
コード例 #2
0
ファイル: file_test.py プロジェクト: alanbbr/luigi
    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())
コード例 #3
0
ファイル: file_test.py プロジェクト: ystopia/luigi
 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))
コード例 #4
0
ファイル: file_test.py プロジェクト: 0xD3ADB33F/luigi
 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))