def test_copy_path_to_exits_path(self, tmpdir): d1 = str(tmpdir.join('test1')) d2 = str(tmpdir.join('test2')) makedirs(d1) makedirs(d2) with pytest.raises(Exception): copy(d1, d2)
def test_copy_without_ignore_error(self, tmpdir): d1 = str(tmpdir.join('test1')) d2 = str(tmpdir.join('test2')) makedirs(d1) makedirs(d2) with pytest.raises(Exception): copy(d1, d2, ignore_errors=False)
def test_copy_non_empty_dir(self, tmpdir): f = str(tmpdir.join('test/test.txt')) d = str(tmpdir.join('test')) d_copy = str(tmpdir.join('test_copy')) os.makedirs(d) touch(f) copy(d, d_copy) assert os.path.exists(d_copy)
def test_copy_file_not_follow_symlink(self, tmpdir): f = str(tmpdir.join('test.txt')) link_f = str(tmpdir.join('test.link')) copy_link_f = str(tmpdir.join('test_copy.link')) touch(f) os.symlink(f, link_f) copy(link_f, copy_link_f, follow_symlinks=False) assert os.path.exists(copy_link_f) assert os.path.islink(copy_link_f)
def test_copy_dir_not_follow_symlink(self, tmpdir): f = str(tmpdir.join('test/test.txt')) d = str(tmpdir.join('test')) link_f = str(tmpdir.join('test/test_link.txt')) d_copy = str(tmpdir.join('test_copy')) new_link_f = str(tmpdir.join('test_copy/test_link.txt')) makedirs(d) touch(f) os.symlink(f, link_f) copy(d, d_copy, follow_symlinks=False) assert os.path.exists(d_copy) assert not os.path.islink(new_link_f)
def test_copy_with_ignore_error(self, tmpdir): d1 = str(tmpdir.join('test1')) d2 = str(tmpdir.join('test2')) makedirs(d1) makedirs(d2) copy(d1, d2, ignore_errors=True)
def test_copy_empty_dir(self, tmpdir): d = str(tmpdir.join('test')) d_copy = str(tmpdir.join('test_copy')) makedirs(d) copy(d, d_copy) assert os.path.exists(d_copy)
def test_copy_file(self, tmpdir): f = str(tmpdir.join('test.txt')) f_copy = str(tmpdir.join('test_copy.txt')) touch(f) copy(f, f_copy) assert os.path.exists(f_copy)