예제 #1
0
 def test_cant_delete_empty_file_ignore_errors(self):
     dir = tempfile.mkdtemp(suffix="a_dir")
     file = open(os.path.join(dir, "test_file"), "w")
     try:
         reusables.remove_empty_files(dir, ignore_errors=True)
     finally:
         file.close()
예제 #2
0
 def test_cant_delete_empty_file_ignore_errors(self):
     dir = tempfile.mkdtemp(suffix="a_dir")
     file = open(os.path.join(dir, "test_file"), "w")
     try:
         reusables.remove_empty_files(dir, ignore_errors=True)
     finally:
         file.close()
예제 #3
0
        def test_cant_delete_empty_file(self):
            dir = tempfile.mkdtemp(suffix="a_dir")
            tf = os.path.join(dir, "test_file")
            file = open(tf, "w")
            try:
                os.chmod(tf, 0o444)
            except Exception:
                pass

            try:
                reusables.remove_empty_files(dir, ignore_errors=False)
            except OSError:
                return True
            else:
                assert False
            finally:
                file.close()
예제 #4
0
        def test_cant_delete_empty_file(self):
            dir = tempfile.mkdtemp(suffix="a_dir")
            tf = os.path.join(dir, "test_file")
            file = open(tf, "w")
            try:
                os.chmod(tf, 0o444)
            except Exception:
                pass

            try:
                reusables.remove_empty_files(dir, ignore_errors=False)
            except OSError:
                return True
            else:
                assert False
            finally:
                file.close()
예제 #5
0
 def test_remove_files(self):
     self._extract_structure()
     delete = reusables.remove_empty_files(test_structure)
     assert len(delete) == 3, (len(delete), delete)
     assert not [x for x in delete if "file" not in x.lower()]
     self._remove_structure()
예제 #6
0
 def test_remove_files(self):
     self._extract_structure()
     delete = reusables.remove_empty_files(test_structure)
     assert len(delete) == 3, (len(delete), delete)
     assert not [x for x in delete if "file" not in x.lower()]
     self._remove_structure()