1. Fredrik Håård
  2. gitapi

Commits

Evgeniy Mineev  committed ae45a57

Add function for processing the file system errors.

In some points git creates files with read-only attribute. And the situation can not be resolved automatically without the processing function.

  • Participants
  • Parent commits 363dc06
  • Branches default

Comments (0)

Files changed (1)

File gitapi/testgitapi.py

View file
  • Ignore whitespace
 from __future__ import with_statement
 import unittest, doctest
 import os, shutil, os.path
-import gitapi 
+import gitapi
+import stat
+
+def onfserror(delegate, path, exec_info):
+    if not os.access(path, os.W_OK):
+        os.chmod(path, stat.S_IWUSR)
+        delegate(path)
+    else:
+        raise
 
 class TestGitAPI(unittest.TestCase):
     """Tests for gitapi.py
             setattr(cls, "assertEquals", cls.assertEqual)
             setattr(cls, "assertNotEquals", cls.assertNotEqual)
         if os.path.exists("./test"):
-            shutil.rmtree("./test")
+            shutil.rmtree("./test", onerror=onfserror)
         os.mkdir("./test")
         assert os.path.exists("./test")
 
     @classmethod
     def tearDownClass(self):
-        shutil.rmtree("test")
+        shutil.rmtree("test", onerror=onfserror)
 
     def test_005_Init(self):
         self.repo.git_init()