Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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