Example #1
0
    def __exit__(self, exc_type: str, exc_val: str, exc_tb: str):
        if self.rootpath is not None and os.path.exists(self.rootpath):
            if self.end_copy:

                # First copy files over
                [
                    _copy_r_with_suffix(tempdir, self.cwd, i)
                    for i, tempdir in enumerate(self.tempdirs)
                ]

            os.chdir(self.cwd)
            [remove(tempdir) for tempdir in self.tempdirs]
Example #2
0
 def test_remove_symlink_follow(self):
     print(self.tempfile)
     remove(self.templink, follow_symlink=True)
     self.assertFalse(os.path.isfile(self.tempfile))
     self.assertFalse(os.path.isdir(self.tempdir))
     self.assertFalse(os.path.islink(self.templink))
Example #3
0
 def test_remove_symlink(self):
     remove(self.templink)
     self.assertTrue(os.path.isfile(self.tempfile))
     self.assertTrue(os.path.isdir(self.tempdir))
     self.assertFalse(os.path.islink(self.templink))
Example #4
0
 def test_remove_folder(self):
     remove(self.tempdir)
     self.assertFalse(os.path.isfile(self.tempfile))
     self.assertFalse(os.path.isdir(self.tempdir))
Example #5
0
 def test_remove_file(self):
     print(os.listdir(test_dir))
     remove(self.tempfile)
     self.assertFalse(os.path.isfile(self.tempfile))
Example #6
0
 def test_remove_symlink_follow(self):
     print(self.tempfile)
     remove(self.templink, follow_symlink=True)
     self.assertFalse(os.path.isfile(self.tempfile))
     self.assertFalse(os.path.isdir(self.tempdir))
     self.assertFalse(os.path.islink(self.templink))
Example #7
0
 def test_remove_symlink(self):
     remove(self.templink)
     self.assertTrue(os.path.isfile(self.tempfile))
     self.assertTrue(os.path.isdir(self.tempdir))
     self.assertFalse(os.path.islink(self.templink))
Example #8
0
 def test_remove_folder(self):
     remove(self.tempdir)
     self.assertFalse(os.path.isfile(self.tempfile))
     self.assertFalse(os.path.isdir(self.tempdir))
Example #9
0
 def test_remove_file(self):
     print(os.listdir(test_dir))
     remove(self.tempfile)
     self.assertFalse(os.path.isfile(self.tempfile))
Example #10
0
 def test_remove_folder(self):
     tempdir = tempfile.mkdtemp(dir=test_dir)
     remove(tempdir)
     self.assertFalse(os.path.isdir(tempdir))
Example #11
0
 def test_remove_file(self):
     tempdir = tempfile.mkdtemp(dir=test_dir)
     tempf = tempfile.mkstemp(dir=tempdir)[1]
     remove(tempf)
     self.assertFalse(os.path.isfile(tempf))
     shutil.rmtree(tempdir)