Eugene Mineev avatar Eugene 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.

Comments (0)

Files changed (1)

gitapi/testgitapi.py

 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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.