def test_copytree_dryrun(self): proxy = _FileModifyProxy(dry_run=True) with TemporaryDirectory(prefix='signac_') as tmp: src = os.path.join(tmp, 'src') dst = os.path.join(tmp, 'dst') _mkdir_p(src) fn_src = os.path.join(src, 'test.txt') fn_dst = os.path.join(dst, 'test.txt') touch(fn_src) self.assertTrue(os.path.isfile(fn_src)) self.assertFalse(os.path.isfile(fn_dst)) proxy.copytree(src, dst) self.assertTrue(os.path.isfile(fn_src)) self.assertFalse(os.path.isfile(fn_dst))
def test_copytree_dryrun(self): proxy = _FileModifyProxy(dry_run=True) with TemporaryDirectory(prefix="signac_") as tmp: src = os.path.join(tmp, "src") dst = os.path.join(tmp, "dst") _mkdir_p(src) fn_src = os.path.join(src, "test.txt") fn_dst = os.path.join(dst, "test.txt") touch(fn_src) assert os.path.isfile(fn_src) assert not os.path.isfile(fn_dst) proxy.copytree(src, dst) assert os.path.isfile(fn_src) assert not os.path.isfile(fn_dst)
def test_copytree(self): proxy = _FileModifyProxy() with TemporaryDirectory(prefix='signac_') as tmp: src = os.path.join(tmp, 'src') dst = os.path.join(tmp, 'dst') _mkdir_p(src) fn_src = os.path.join(src, 'test.txt') fn_dst = os.path.join(dst, 'test.txt') touch(fn_src) assert os.path.isfile(fn_src) assert not os.path.isfile(fn_dst) proxy.copytree(src, dst) assert os.path.isfile(fn_src) assert os.path.isfile(fn_dst)
def _reset_differing_jobs(self, jobs): for i, job in enumerate(jobs): with job: with open('test', 'w') as file: file.write('x' * i) _mkdir_p('subdir') with open('subdir/test2', 'w') as file: file.write('x' * i) def differs(fn): x = set() for job in jobs: with open(job.fn(fn)) as file: x.add(file.read()) return len(x) > 1 return differs
def _reset_differing_jobs(self, jobs): for i, job in enumerate(jobs): with job: with open("test", "w") as file: file.write("x" * i) _mkdir_p("subdir") with open("subdir/test2", "w") as file: file.write("x" * i) def differs(fn): x = set() for job in jobs: with open(job.fn(fn)) as file: x.add(file.read()) return len(x) > 1 return differs